public async Task <PrintingEditionViewModel> GetPrintingEditionById(int id)
        {
            PrintingEdition printingEdition = await _printEditRepository.Get(id);

            PrintingEditionViewModel printingEditionModel = _mapper.Map <PrintingEditionViewModel>(printingEdition);

            return(printingEditionModel);
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <PrintingEditionViewModel> > GetAllPrintingEditions()
        {
            IEnumerable <AuthorInPrintingEditions> authorsInPriningEditions = _authorInPrintingEditionRepository.GetWithInclude();
            var modelsList = new List <PrintingEditionViewModel>();

            foreach (AuthorInPrintingEditions authInPrintingEdition in authorsInPriningEditions)
            {
                PrintingEdition printingEdition = await _printingEditionRepository.Get(authInPrintingEdition.PrintingEditionId);

                modelsList.Add(_mapper.Map <PrintingEditionViewModel>(printingEdition));
            }

            return(modelsList);
        }
Ejemplo n.º 3
0
        public async Task <int> CreateOrder(OrderViewModel model)
        {
            Order order                 = _mapper.Map <Order>(model);
            var   printingEditions      = new List <PrintingEdition>();
            var   printEditionsInOrders = new List <PrintingEditionsInOrders>();

            order.DatePurchase = DateTime.UtcNow;

            await _orderRepository.Create(order);

            foreach (AuthorsInPrintingEditionsViewModel printEd in model.Products)
            {
                printingEditions.Add(await _printEditRepository.Get(printEd.PrtintingEditionId));
            }

            foreach (PrintingEdition print in printingEditions)
            {
                printEditionsInOrders.Add(new PrintingEditionsInOrders
                {
                    PrintingEditionId    = print.Id,
                    OrderId              = order.Id,
                    OrderAmount          = model.OrderAmount,
                    PrintEditionQuantity = model.Products.Find(x => x.PrtintingEditionId == print.Id).PrintinEditionQuantityForOrder
                });
            }

            _printEditInOrdersRepository.AddPrintingEditionInOrders(printEditionsInOrders);

            return(order.Id);
        }
Ejemplo n.º 4
0
        public List <PrintingEditionModel> GetPrintingEditionsAdmin(bool isBook = true, bool isNewspaper = true, bool isJournal = true, string field = Constants.DEFAULTEDITIONSORT, string orderAsc = Constants.DEFAULTSORTORDER, int page = Constants.DEFAULTPAGE, bool getRemoved = false)
        {
            var filter = new PrintingEditionFilterModel
            {
                IsBook      = isBook,
                IsJournal   = isJournal,
                IsNewspaper = isNewspaper
            };
            var dbPrintingEditions = _printingEditionRepository.Get(filter, field, orderAsc == Constants.DEFAULTSORTORDER, getRemoved, page, Constants.ADMINPRINTINGEDITIONPAGESIZE).ToList();
            var printingEditions   = new List <PrintingEditionModel>();

            foreach (var printingEdition in dbPrintingEditions)
            {
                var mappedEdition = _mapper.Map <PrintingEditionModel>(printingEdition);
                mappedEdition.Authors = printingEdition.Authors.Select(author => author.Name).ToList();
                printingEditions.Add(mappedEdition);
            }
            return(printingEditions);
        }
Ejemplo n.º 5
0
        public async Task <IEnumerable <AuthorViewModel> > GetPritningEditionAuthors(int id)
        {
            PrintingEdition printingEdition = await _printEditRepository.Get(id);

            IEnumerable <AuthorInPrintingEditions> authors = _authorInPrintingEditionRepository.FindByPrintingEditionID(printingEdition.Id);
            var modelsList = new List <AuthorViewModel>();

            foreach (AuthorInPrintingEditions author in authors)
            {
                AuthorViewModel model = _mapper.Map <AuthorViewModel>(author);
                modelsList.Add(model);
            }
            ;

            return(modelsList);
        }