public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var userRepo = new Repos.UserRepo(); var billingrepo = new Repos.BillingAddressRepo(); var deliveryRepo = new Repos.DeliveryAddressRepo(); var contactRepo = new Repos.CustomerContactRepo(); //Checking if email already exists var userEmail = model.Email; var result = userRepo.GetUser(userEmail); if (result == null) { var contact = CreateContact(model); var billing = CreateBAddress(model); var delivery = CreateDAddress(model); var user = CreateUser(model, contact, billing, delivery); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Register", "Account")); //AddErrors(); } } // If we got this far, something failed, redisplay form return(View(model)); }
public console.Models.tbl_User FindUser(DreamTech.Models.LoginViewModel model) { var repo = new Repos.UserRepo(); var user = repo.GetLoginDetails(model.Email, model.Password); if (user == null) { return(null); } else { return(user); } }
public tbl_User CreateUser(RegisterViewModel model, tbl_CustomerContact contact, tbl_BillingAddress billing, tbl_DelivetyAddresses delivery) { var userRepo = new Repos.UserRepo(); var newUser = new tbl_User(); newUser.user_name = model.Name; newUser.user_surname = model.Surname; newUser.email_address = model.Email; newUser.password = model.Password; newUser.delivery_id = delivery.delivery_id; newUser.billing_id = billing.billing_id; newUser.contact_id = contact.contact_id; userRepo.SaveUser(newUser); return(newUser); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } var repo = new Repos.UserRepo(); var user = repo.GetLoginDetails(model.Email, model.Password); if (user == null) { ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } else { System.Web.Security.FormsAuthentication.SetAuthCookie(model.Email, false); return(RedirectToLocal(returnUrl)); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true //var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false); //switch (result) //{ // case SignInStatus.Success: // return RedirectToLocal(returnUrl); // case SignInStatus.LockedOut: // return View("Lockout"); // case SignInStatus.RequiresVerification: // return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe }); // case SignInStatus.Failure: // default: // ModelState.AddModelError("", "Invalid login attempt."); // return View(model); //} }
public void CreateOrder(console.Models.tbl_Cart cart, console.Models.tbl_User user, console.Models.tbl_PromoCode promo, console.Models.tbl_OrderStatus status) { console.Models.tbl_Order order = new console.Models.tbl_Order(); var repo = new Repos.OrderRepo(); var statRepo = new Repos.OrderStatusRepo(); var userRepo = new Repos.UserRepo(); var promoRepo = new Repos.PromotionsRepo(); var statObject = statRepo.GetStatus(1); var userObject = userRepo.GetUserById(1); var promoObject = promoRepo.GetPromoById(1); order.user_id = userObject.user_id; order.cart_ref = cart.cart_ref; order.order_status_id = statObject.status_id; order.delivery_address_id = userObject.delivery_id; order.order_total = cart.cart_total; order.promo_id = promoObject.promo_id; repo.SaveOrder(order); RemoveProdsFromCart(); }