public IActionResult Create()
        {
            OrdersListingModel model = new OrdersListingModel
            {
                Addresses = this.ordersService.GetAllUserAddresses(this.User.Identity.Name).Select(x => new AddressViewModel
                {
                    Id = x.Id,
                    AdditionalInformation = x.AdditionalInformation,
                    City     = x.City,
                    Country  = x.Country,
                    Postcode = x.Postcode,
                    Street   = x.Street
                }).ToList(),
                ResipientInformation = new UserViewModel
                {
                    FullName    = this.ordersService.GetUser(this.User.Identity.Name).FirstName + " " + this.ordersService.GetUser(this.User.Identity.Name).LastName,
                    PhoneNumber = this.ordersService.GetUser(this.User.Identity.Name).PhoneNumber
                },
                CartMovies = this.ordersService.GetCartMovies(this.User.Identity.Name).Select(x => new CartMovieViewModel
                {
                    Id        = x.Key.Id,
                    Name      = x.Key.Name,
                    PosterUrl = x.Key.PosterUrl,
                    Price     = x.Key.BluRayPrice,
                    Quantity  = x.Value
                }).ToList()
            };

            return(View(model));
        }
Пример #2
0
 public static string ToHtml(this OrdersListingModel order)
 => $@"
             <tr>
                 <td>{order.Id}</td>
                 <td>{order.Customer}</td>
                 <td>{order.Product}</td>
                 <td>{order.SalePrice}</td>
                 <td>{order.OrderedOn}</td>
             </tr>";
        public IActionResult Create(OrderInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                OrdersListingModel model = new OrdersListingModel
                {
                    Addresses = this.ordersService.GetAllUserAddresses(this.User.Identity.Name).Select(x => new AddressViewModel
                    {
                        Id = x.Id,
                        AdditionalInformation = x.AdditionalInformation,
                        City     = x.City,
                        Country  = x.Country,
                        Postcode = x.Postcode,
                        Street   = x.Street
                    }).ToList(),
                    ResipientInformation = new UserViewModel
                    {
                        FullName    = input.ResipientName,
                        PhoneNumber = input.PhoneNumber
                    },
                    CartMovies = this.ordersService.GetCartMovies(this.User.Identity.Name).Select(x => new CartMovieViewModel
                    {
                        Id        = x.Key.Id,
                        Name      = x.Key.Name,
                        PosterUrl = x.Key.PosterUrl,
                        Price     = x.Key.BluRayPrice,
                        Quantity  = x.Value
                    }).ToList()
                };

                return(this.View(model));
            }

            this.ordersService.CreateAnOrder(input.CartPrice, input.DeliveryType, input.PaymentType, input.AddressId, this.User.Identity.Name, input.PhoneNumber);

            return(this.Redirect("/Orders/Summary"));
        }