internal Price GetFromDataBase(IBookShopContext context) { var price = context.Prices.FirstOrDefault(x => x.Amount == this.Ammount && x.Currency == this.Currency); if (price == null) { price = new Price(this.Ammount, this.Currency); context.Prices.Add(price); } return(price); }
internal void AddToDatabase(IBookShopContext context, Price price, IEnumerable <Author> authors) { var book = context.Books.FirstOrDefault(x => x.Name == this.Name && x.Description == this.Description); if (book == null) { var newBook = new Book(this.Name, this.Description, price, new Stock(this.Ammount), authors); context.Books.Add(newBook); } book.Stock = new Stock(book.Stock.Amount + this.Ammount); }
internal Author GetFromDatabase(IBookShopContext context) { var author = context.Authors.FirstOrDefault(x => x.Name == this.Name && x.Surname == this.Surname); if (author == null) { var authorToAdd = new Author(this.Name, this.Surname, this.Biography); context.Authors.Add(authorToAdd); return(authorToAdd); } else { return(author); } }
public EFRepository(IBookShopContext context) { this.context = context; this.set = context.Set <T>(); }
public BookShopData(IBookShopContext context) { this.context = context; this.repositories = new Dictionary <Type, object>(); }
internal void AddAuthors(IEnumerable <AuthorDto> authors, IBookShopContext context) { List <Author> authorsindb = new List <Author>(); Authors = authors.Select(x => x.GetFromDatabase(context)).ToList(); }
public AuthorsController(IBookShopContext context) { this.context = context; }
public BookRepository(IBookShopContext context, IMapper mapper) { this.context = context; this.mapper = mapper; }
public BooksController(IBookShopContext context) { this.context = context; }
public ReportingService(IBookShopContext context, IExcelCreator excelCreator) { this.context = context; this.excelCreator = excelCreator; }
public PurchaseService(IBookShopContext context, IMapper mapper, IMediator mediator) { this.context = context; this.mapper = mapper; this.mediator = mediator; }
public SupplyBookService(IBookShopContext context) { this.context = context; }
public CategoriesController(IBookShopContext context) { this.context = context; }