This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace BooksWebApi.Models | |
{ | |
public class CategoryModel | |
{ | |
public string Description { get; set; } | |
public ICollection<BookWithoutCategoryModel> Books { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.DataAnnotations; | |
namespace BooksWebApi.Models | |
{ | |
public class LoginModel | |
{ | |
[Required] | |
public string UserName { get; set; } | |
[Required] | |
public string Password { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BooksWebApi.Entities; | |
using System; | |
namespace BooksWebApi.Models | |
{ | |
public class UpdateBookModel | |
{ | |
public string Name { get; set; } | |
public string AuthorName { get; set; } | |
public int Edition { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using BooksWebApi.Data; | |
using BooksWebApi.Entities; | |
using Microsoft.EntityFrameworkCore; | |
public class CrudRepository : ICrudRepository | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BooksWebApi.Entities; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
namespace BooksWebApi.Repository | |
{ | |
public interface ICrudRepository | |
{ | |
void Add<T>(T entity) where T : class; | |
void Delete<T>(T entity) where T : class; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"ConnectionStrings": { | |
"DefaultConnection": "Data Source=HOST\\SQLEXPRESS;Initial Catalog=DbBooksCat;Connect Timeout=30;Encrypt=False; Integrated Security=SSPI;" | |
}, | |
"Logging": { | |
"IncludeScopes": false, | |
"Debug": { | |
"LogLevel": { | |
"Default": "Debug" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BooksCatalogDbContext : IdentityDbContext | |
{ | |
public BooksCatalogDbContext(DbContextOptions<BooksCatalogDbContext> options) | |
: base(options) | |
{ | |
} | |
public DbSet<Book> Books { get; set; } | |
public DbSet<Category> Categories { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public IConfiguration Configuration { get; set; } | |
public Startup(IHostingEnvironment env) | |
{ | |
var builder = new ConfigurationBuilder() | |
.SetBasePath(env.ContentRootPath) | |
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) | |
.AddEnvironmentVariables(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace BooksWebApi.Entities | |
{ | |
public class Category | |
{ | |
public long Id { get; set; } | |
public string Description { get; set; } | |
public List<Book>Books { get; set; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Identity; | |
namespace BooksWebApi.Entities | |
{ | |
public class User : IdentityUser | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
} | |
} |