public static MyInfoViewModel From(Models.User user) { MyInfoViewModel model = new MyInfoViewModel(); model.Contact = ContactViewModel.From(user.Contact); model.Email = user.Email; model.Contact = ContactViewModel.From(user.Contact); model.IsSignForNews = user.IsSignedForNews; return(model); }
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 })); }
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)); }
public ActionResult LoginAndCheckout(string email, string password, Cart cart) { if (userService.AuthenticateUser(email, password)) { User user = daoTemplate.FindUniqueByField <User>(Models.User.EmailProperty, email); FormsAuthentication.SetAuthCookie(email, true); return(View("EnterShippingDetails", new EnterShippingDetailsViewModel() { Contact = ContactViewModel.From(user.Contact), User = user, Cart = cart, DeliverPrices = daoTemplate.FindAll <DeliverPrices>()[0] })); } else { ModelState.AddModelError("login", "Неправильное имя пользователя или пароль"); return(View("LoginOrRegister", cart)); } }