public ActionResult OrdersPageForDate(int dateId)
        {
            var userName = User.Identity.Name.ToLower();
            var loginId  = loginService.GetLoginByName(userName)?.Id ?? 0;

            var date        = dateService.GetDate(dateId);
            var play        = playService.GetPlay(date.PlayId);
            var datesOfPlay = dateService.GetDatesOfPlay(play.Id).ToList();

            var dates = datesOfPlay.Select(q => new DateViewModel {
                Id   = q.Id,
                Date = q.PlayDate
            }).ToList();

            var orders = new OrdersForDateViewModel
            {
                DateId     = dateId,
                LoginId    = loginId,
                Categories = new List <CategoriesForTableViewModel>(),
                Dates      = dates,
                PlayName   = play.Name,
                AuthorName = play.Author.Name
            };

            var categories = categoriesService.GetCategories();

            orders.Categories = categories.Select(category =>
            {
                var ticketsPaidCount    = ordersService.GetPaidOrders(category.Id, dateId);
                var orderedTicketsCount = ordersService.GetNonPaidOrders(category.Id, dateId);

                return(new CategoriesForTableViewModel
                {
                    Category = category.Name,
                    AvailableTickets = category.TotalTickets - ticketsPaidCount - orderedTicketsCount,
                    TicketPrice = category.TicketPrice,
                    TotalTickets = category.TotalTickets,
                    OrderedTickets = orderedTicketsCount,
                    PaidTickets = ticketsPaidCount,
                    CategoryId = category.Id,
                    Quantity = 0
                });
            }).ToList();

            return(View(orders));
        }
Exemplo n.º 2
0
 public DateDTO GetDate(int id)
 {
     return(dateService.GetDate(id));
 }
Exemplo n.º 3
0
        public async System.Threading.Tasks.Task <IActionResult> ConfirmOrderAsync(double totalPrice)
        {
            string          email     = User.Identity.Name;
            string          hostUrl   = Request.Scheme + "://" + Request.Host;
            List <Sneakers> orderList = new List <Sneakers>();
            List <Purchase> purchases = purchaseRepository.GetPurchaseByUserId(Guid.Parse(userManager.GetUserId(HttpContext.User)));

            foreach (Purchase purchase in purchases)
            {
                orderList.Add(sneakersRepository.GetSneakersById(purchase.SneakersId));
            }
            string uid = Guid.Parse(userManager.GetUserId(HttpContext.User)).ToString();
            await messageSender.SendMessage(email, "Order confirmation message",
                                            messageSender.BuildPreConfirmationMessage(email, dateService.GetDate(), orderList, hostUrl, uid));

            return(RedirectToAction("OrderConfirmation"));
        }