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);
        }
Example #3
0
        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>();
 }
Example #5
0
 public BookShopData(IBookShopContext context)
 {
     this.context      = context;
     this.repositories = new Dictionary <Type, object>();
 }
Example #6
0
        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;
 }
Example #8
0
 public BookRepository(IBookShopContext context, IMapper mapper)
 {
     this.context = context;
     this.mapper  = mapper;
 }
Example #9
0
 public BooksController(IBookShopContext context)
 {
     this.context = context;
 }
Example #10
0
 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;
 }
Example #13
0
 public CategoriesController(IBookShopContext context)
 {
     this.context = context;
 }