Exemplo n.º 1
0
 public static OrderShippingInfo From(EnterShippingDetailsViewModel viewModel)
 {
     OrderShippingInfo info = new OrderShippingInfo();            
     info.Contact = Contact.From(viewModel.Contact);
     info.DeliverType = viewModel.DeliverType;
     info.PaymentType = viewModel.PaymentType;
     info.Comment = viewModel.Comment;
     
     return info;
 }
Exemplo n.º 2
0
 public ActionResult EnterShippingDetails(Cart cart)
 {
     if (cart.Summ() < 300)
     {
         ModelState.AddModelError("summ", "Минимальная сумма заказа 300 рублей");
         return View("Review", new ReviewCartViewModel { Cart = cart });
     }
     var model = new EnterShippingDetailsViewModel()
                     {
                         Contact = ContactViewModel.From(CurrentUser().Contact),
                         User = CurrentUser(),
                         Cart = cart,
                         DeliverPrices = daoTemplate.FindAll<DeliverPrices>()[0]
                     };
     return View("EnterShippingDetails", model);
 }
Exemplo n.º 3
0
        public ActionResult Send(EnterShippingDetailsViewModel viewModel, Cart cart)
        {
            if (!ModelState.IsValid || viewModel.DeliverType == DeliverType.NULL || viewModel.PaymentType == PaymentType.NULL)
            {
                if (viewModel.DeliverType == DeliverType.NULL)
                {
                    ModelState.AddModelError("DeliverType", "Выберите способ доставки");
                }

                if (viewModel.PaymentType == PaymentType.NULL)
                {
                    ModelState.AddModelError("PaymentType", "Выберите способ оплаты");
                }

                return View("EnterShippingDetails", new EnterShippingDetailsViewModel()
                                                        {
                                                            Contact = ContactViewModel.From(CurrentUser().Contact),
                                                            Cart = cart,
                                                            User = CurrentUser(),
                                                            DeliverPrices = daoTemplate.FindAll<DeliverPrices>()[0],
                                                            DeliverType = viewModel.DeliverType,
                                                            Comment = viewModel.Comment

                });
            }

            OrderShippingInfo info = OrderShippingInfo.From(viewModel);

            AddOrderResult result = orderService.AddOrder(cart, CurrentUser(), info);

            var message = MailService.RenderViewToString("~/Views/MailTemplates/NewOrder.aspx", result.Order, this.ControllerContext);
            BillViewModel model = new BillViewModel()
                            {
                                Price = result.Order.SummWithDiscount,
                                Address = result.Order.ShippingDetails.AddressBill(),
                                Uid = result.Order.Uid,
                                UserName = result.Order.ShippingDetails.FullName
                            };
            var attachment = "";
            if (result.Order.PaymentType == PaymentType.Bank)
            {
                attachment = MailService.RenderViewToString("~/Views/Order/Bill.aspx", model, this.ControllerContext);
            }
            MailService.Send("Новый заказ - Elfam.ru", message, result.Order.User.Email, attachment, null);

            message = MailService.RenderViewToString("~/Views/MailTemplates/NewOrderAdmin.aspx", result.Order, this.ControllerContext);
            //            MailService.Send("Новый заказ № " + result.Order.Uid, message, "*****@*****.**");
            mailService.SendCcAdmins("Новый заказ № " + result.Order.Uid, message, "*****@*****.**");

            cart.Items.Clear();
            return RedirectToAction("DetailsUser", "Order", new { id = result.Order.Uid });
        }