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
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.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 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; | |
namespace BooksWebApi.Models | |
{ | |
public class BookWithoutCategoryModel | |
{ | |
public string Name { get; set; } | |
public string AuthorName { get; set; } | |
public int Edition { get; set; } | |
public DateTime PublicationDate { 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 AutoMapper; | |
using BooksWebApi.Entities; | |
namespace BooksWebApi.Models | |
{ | |
public class BookMappingProfile : Profile | |
{ | |
public BookMappingProfile() | |
{ | |
CreateMap<Book, BookModel>() |
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 AutoMapper; | |
namespace BooksWebApi.Models | |
{ | |
public class CategoryMappingProfile : Profile | |
{ | |
public CategoryMappingProfile() | |
{ | |
CreateMap<Category, CategoryModel>().ForMember(a => a.Books, opt => opt.ResolveUsing(c => c.Books)) |
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.Threading.Tasks; | |
using AutoMapper; | |
using BooksWebApi.Entities; | |
using BooksWebApi.Models; | |
using BooksWebApi.Repository; | |
using Microsoft.AspNetCore.Authorization; | |
using Microsoft.AspNetCore.Mvc; |
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.Threading.Tasks; | |
using BooksWebApi.Data; | |
using BooksWebApi.Entities; | |
using BooksWebApi.Models; | |
using Microsoft.AspNetCore.Identity; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Logging; | |
namespace BooksWebApi.Controllers |
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 Microsoft.AspNetCore.Identity; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace BooksWebApi.Data | |
{ | |
public static class DataInitializer |