public ActionResult Create(ViewBuyer vbuyer) { if (ModelState.IsValid) { BuyerAddress address = new BuyerAddress(); address.Area = areaRepo.Get(vbuyer.Area); address.City = cityRepo.Get(vbuyer.City); address.Block = vbuyer.Block; address.House = vbuyer.House; address.Road = vbuyer.House; BuyerLogin login = new BuyerLogin(); login.Username = vbuyer.Username; login.Password = vbuyer.Password; BuyerApproval approval = new BuyerApproval(); approval.Status = false; Buyer buyer = new Buyer(); buyer.FirstName = vbuyer.FirstName; buyer.LastName = vbuyer.LastName; buyer.Email = vbuyer.Email; buyer.Phone = vbuyer.Phone; buyer.Gender = vbuyer.Gender; buyer.Address = address; buyer.LoginData = login; buyer.Approval = approval; buyerRepo.Insert(buyer); return(RedirectToAction("Index", "Home")); } return(View(vbuyer)); }
public int Delete(int id) { BuyerLogin loginToDelete = context.BuyerLogins.SingleOrDefault(l => l.Id == id); context.BuyerLogins.Remove(loginToDelete); return(context.SaveChanges()); }
public int Update(BuyerLogin credential) { BuyerLogin credentialToUpdate = context.BuyerLogins.SingleOrDefault(c => c.Id == credential.Id); credentialToUpdate.Username = credential.Username; credentialToUpdate.Password = credential.Password; return(context.SaveChanges()); }
public ActionResult BuyerLogin(BuyerLogin login, string ReturnUrl = "") { string message = ""; using (dbMyEFarmingProjectEntities dc = new dbMyEFarmingProjectEntities()) { var v = dc.Tbl_BuyerProfile.Where(a => a.BEmailId == login.BEmailId).FirstOrDefault(); Session["BId"] = v.BId; Session["RoleAsBuyer"] = v.IsBuyerActivated; Session["RoleAsSeller"] = v.IsSellerActivated; if (v != null) { if (!v.BIsEmailVarified) { ViewBag.Message = "Please verify your email first"; return(View()); } if (string.Compare(Crypto.Hash(login.BPassword), v.BPassword) == 0) { int timeout = login.RememberMe ? 525600 : 20; // 525600 min = 1 year var ticket = new FormsAuthenticationTicket(login.BEmailId, login.RememberMe, timeout); string encrypted = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted); cookie.Expires = DateTime.Now.AddMinutes(timeout); cookie.HttpOnly = true; Response.Cookies.Add(cookie); if (Url.IsLocalUrl(ReturnUrl)) { return(Redirect(ReturnUrl)); } else { return(RedirectToAction("Index", "BuyerProduct")); } } else { message = "Invalid credential provided"; } } else { message = "Invalid credential provided"; } } ViewBag.Message = message; return(View()); }
public ActionResult BuyerLogin(ViewUserLogin vUserLogin) { if (ModelState.IsValid) { BuyerLoginRepository loginRepo = new BuyerLoginRepository(); BuyerLogin login = new BuyerLogin(); login.Username = vUserLogin.Username; login.Password = vUserLogin.Password; int id = loginRepo.Match(login).Id; return(RedirectToAction("Index", "Buyer", new { @id = id })); } else { return(View(vUserLogin)); } }
public BuyerLogin Match(BuyerLogin credential) { BuyerLogin credentialFromDB = context.BuyerLogins.SingleOrDefault(c => c.Username == credential.Username && c.Password == credential.Password); return(credentialFromDB); }
public int Insert(BuyerLogin credential) { context.BuyerLogins.Add(credential); return(context.SaveChanges()); }