private OrderDTO MapUserOrder(CheckOutUserModel model) { return(new OrderDTO() { Comment = model.Comment, DeliveryMethod = model.DeliveryMethod, PaymentMethod = model.PaymentMethod, UserId = userService.GetUser(User.Identity.Name).Id }); }
private RegistrationDTO MapReg(CheckOutUserModel model) { return(new RegistrationDTO() { userId = userService.GetUser(User.Identity.Name).Id, Address = model.GuestModel.Address, Email = model.GuestModel.Email, FirstName = model.GuestModel.FirstName, LastName = model.GuestModel.LastName, HashPassword = model.GuestModel.RegModel.Password.GetHashCode(), PhoneNumber = model.GuestModel.PhoneNumber, ZipCode = model.GuestModel.ZipCode, IP = Request.UserHostAddress }); }
public ActionResult CheckOut() { int userId = userService.GetUser(User.Identity.Name).Id; if (cartService.GetCurrentOrder(userId).OrderItems.Count != 0) { CheckOutUserModel chum = new CheckOutUserModel(); chum.GuestModel = new CheckOutGuestModel(); chum.GuestModel.RegModel = new RegistrationModel(); return(View(chum)); } else { return(HttpNotFound()); } }
public ActionResult CheckOut(CheckOutUserModel model) { int userId; RegistrationDTO regDTO; ServiceResult <RegistrationDTO> r; if (ModelState.IsValid) { if (model.GuestModel != null) { if (!model.GuestModel.CreateAccount) { cartService.AcceptGuestOrder(MapGuestOrder(model)); userId = userService.GetUser(User.Identity.Name).Id.GetHashCode(); return(RedirectToAction("info", "Home", new { str = "order", userid = userId })); } else { regDTO = MapReg(model); r = userService.RegisterUser(regDTO, Url.Action("ConfirmEmail", "Account", new { userid = regDTO.userId }, Request.Url.Scheme)); if (r.Exception == null) { cartService.AcceptGuestOrder(MapGuestOrder(model)); return(RedirectToAction("info", "Home", new { str = "email", userid = regDTO.userId })); } else { ModelState.AddModelError("GuestModel." + r.Exception.Property, r.Exception.Message); return(View(model)); } } } else { cartService.AcceptUserOrder(MapUserOrder(model)); userId = userService.GetUser(User.Identity.Name).Id.GetHashCode(); return(RedirectToAction("info", "Home", new { str = "order", userid = userId })); } } else { return(View(model)); } }
private OrderDTO MapGuestOrder(CheckOutUserModel model) { return(new OrderDTO() { Comment = model.Comment, DeliveryMethod = model.DeliveryMethod, PaymentMethod = model.PaymentMethod, UserId = userService.GetUser(User.Identity.Name).Id, User = new UserDTO() { FirstName = model.GuestModel.FirstName, LastName = model.GuestModel.LastName, Email = model.GuestModel.Email, PhoneNumber = model.GuestModel.PhoneNumber, Address = model.GuestModel.Address, ZipCode = model.GuestModel.ZipCode } }); }