public ActionResult ChangePassword(LoginViewModel user) { if (user.ChangedUserName != null) { Login log = new Login(); List<Login> l = new List<Login>(); l = ld.checkLog(user.ChangedUserName, user.Password); if (l != null) { log.LoginID = l[0].LoginID; log.Password = user.ChangedPassword; log.UserID = l[0].UserID; log.UserName = l[0].UserName; log.UserTypeID = l[0].UserTypeID; db.Entry(log).State = EntityState.Modified; db.SaveChanges(); return View("Login"); } else { ModelState.AddModelError("", "Username and password is incorrect!"); } } return View(); }
public ActionResult ResetPassword(UserViewModel uv) { List<Login> l = new List<Login>(); Login log = new Login(); // ll.LoginID = r.LoginID; LoginDAL ld = new LoginDAL(); l = ld.checkLogdet(uv.EmailID); if (l != null) { log.LoginID = l[0].LoginID; log.Password = l[0].UserName; log.UserID = l[0].UserID; log.UserName = l[0].UserName; log.UserTypeID = l[0].UserTypeID; db.Entry(log).State = EntityState.Modified; db.SaveChanges(); ViewBag.ac = "Create"; } return RedirectToAction("Create"); }
public ActionResult Create(UserViewModel uv) { User usr = new RouteOptimization.Infrastructure.User(); usr.EmailID = uv.EmailID; usr.FirstName = uv.FirstName; usr.LastName = uv.LastName; usr.Phone = uv.Phone; usr.UserTypeID = uv.UserTypeId; Address ad = new Address(); ad.Address1 = uv.Address1; ad.Address2 = uv.Address2; ad.PostalCode = uv.PostalCode; ad.CityID = uv.CityId; ad.CountryID = uv.CountryId; ad.ProvinceID = uv.ProvinceId; // ad.CityID = RedeemTransaction.CityDetails; // ad.CountryID = RedeemTransaction.CountryDetails; // ad.ProvinceID = RedeemTransaction.ProvinceDetails; // int i=0; Login lg = new Login(); lg.UserName = uv.EmailID; lg.Password = uv.EmailID; lg.UserTypeID = uv.UserTypeId; int addid = 0; if (ModelState.IsValid) { ud.AddAddress(ad); var result = db.Addresses.OrderByDescending(x => x.AddressID).First(); addid = result.AddressID; } if (ModelState.IsValid) { if (addid != 0) { usr.AddressID = addid; ud.AddUser(usr); } } if (ModelState.IsValid) { var res = db.Users.OrderByDescending(x => x.UserID).First(); lg.UserID = res.UserID; ud.AddLogin(lg); } if (ModelState.IsValid) { UserAvailability ua = new UserAvailability(); ua.UserID = usr.UserID; ua.Status = "AV"; ud.AddUAvail(ua); return RedirectToAction("Create"); } // ViewBag.UserTypeID = new SelectList(db.UserTypes, "UserTypeID", "Description"); return View(uv);//user); }
public void AddLogin(Login lg) { db.Logins.Add(lg); db.SaveChanges(); }