public ActionResult Appointment(AppointmentRecords appointmodel) { using (IPHISEntities dbmodel = new IPHISEntities()) { Appointment appointmodel1 = new Appointment(); appointmodel1.DoctorId = appointmodel.DoctorId; appointmodel1.HospitalId = appointmodel.HospitalId; appointmodel1.AppointmentDate = appointmodel.AppointmentDate; appointmodel1.StartTime = appointmodel.StartTime; appointmodel1.EndTime = appointmodel.EndTime; appointmodel1.ProblemId = appointmodel.ProblemId; dbmodel.Appointments.Add(appointmodel1); try { dbmodel.SaveChanges(); } catch (DbEntityValidationException e) { Console.WriteLine(e); } } ModelState.Clear(); ViewBag.SuccessMessage = "Appointment Booked Successfully.Confirmation Mail Will Be Sent To You Shortly."; return(View("Appointment", new AppointmentRecords())); }
public ActionResult ResetPassword(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { using (IPHISEntities dc = new IPHISEntities()) { var user = dc.Users.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault(); if (user != null) { user.Password = Crypto.Hash(model.NewPassword); user.ResetPasswordCode = ""; dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "New password updated successfully"; return(RedirectToAction("Login", "User")); } } } else { message = "Something invalid"; } ViewBag.Message = message; return(View(model)); }
public ActionResult ForgotPassword(string EmailAddress) { //Verify Email ID //Generate Reset password link //Send Email string message = " "; using (IPHISEntities dc = new IPHISEntities()) { var account = dc.Users.Where(a => a.EmailAddress == EmailAddress).FirstOrDefault(); if (account != null) { //Send email for reset password string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail(account.EmailAddress, resetCode, "ResetPassword"); account.ResetPasswordCode = resetCode; //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property //in our model class in part 1 dc.Configuration.ValidateOnSaveEnabled = false; dc.SaveChanges(); message = "Reset password link has been sent to your email id."; } else { message = "Account not found"; } } ViewBag.Message = message; return(View()); }
public ActionResult Registration(User usermodel) { User usermodel1 = new User(); using (IPHISEntities dbmodel = new IPHISEntities()) { dbmodel.Users.Add(usermodel); dbmodel.SaveChanges(); //var emp = dbmodel.User_Addr_Sec_Ans(usermodel.FirstName, usermodel.MiddleName, usermodel.LastName, usermodel.EmailAddress, usermodel.Password, usermodel.PhoneNumber, usermodel.UserUniqueId, usermodel.UserTypeId); } ModelState.Clear(); ViewBag.SuccessMessage = "Registration Successfull."; return(View("Registration", new User_Addr_Sec_Ans_Result())); }
public ActionResult VerifyAccount(string id) { bool Status = false; using (IPHISEntities dc = new IPHISEntities()) { dc.Configuration.ValidateOnSaveEnabled = false; // This line I have added here to avoid // Confirm password does not match issue on save changes var v = dc.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault(); if (v != null) { v.IsEmailVerified = true; dc.SaveChanges(); Status = true; } else { ViewBag.Message = "Invalid Request"; } } ViewBag.Status = Status; return(View()); }
public ActionResult Registration(UserRecords usermodel) { usermodel.AddressId = 1; usermodel.UserId = 12; usermodel.LoginErrorMessage = "No error"; using (IPHISEntities dbmodel = new IPHISEntities()) { List <UserType> list = dbmodel.UserTypes.ToList(); ViewBag.UserTypeList = new SelectList(list, "UserTypeId", "TypeName"); List <Country> Clist = dbmodel.Countries.ToList(); ViewBag.CountryList = new SelectList(Clist, "CountryId", "CountryName"); List <State> Slist = dbmodel.States.ToList(); ViewBag.StateList = new SelectList(Slist, "StateId", "StateName"); List <City> Cilist = dbmodel.Cities.ToList(); ViewBag.CityList = new SelectList(Cilist, "CityId", "CityName"); ////dbmodel.Addresses.Add(usermodel); //dbmodel.Users.Add(usermodel); //usermodel1.UserTypesCollection = dbmodel.UserTypes.ToList<UserType>(); //dbmodel.SaveChanges(); ////var emp = dbmodel.User_Addr_Sec_Ans(usermodel.FirstName, usermodel.MiddleName, usermodel.LastName, usermodel.EmailAddress, usermodel.Password, usermodel.PhoneNumber, usermodel.UserUniqueId, usermodel.UserTypeId); User usermodel1 = new User(); usermodel1.FirstName = usermodel.FirstName; usermodel1.MiddleName = usermodel.MiddleName; usermodel1.LastName = usermodel.LastName; usermodel1.EmailAddress = usermodel.EmailAddress; usermodel1.Password = usermodel.Password; usermodel1.PhoneNumber = usermodel.PhoneNumber; usermodel1.UserUniqueId = usermodel.UserUniqueId; usermodel1.UserTypeId = usermodel.UserTypeId; usermodel1.CountryId = usermodel.CountryId; usermodel1.StateId = usermodel.StateId; usermodel1.CityId = usermodel.CityId; dbmodel.Users.Add(usermodel1); try { dbmodel.SaveChanges(); } catch (DbEntityValidationException e) { Console.WriteLine(e); } int LatestUserId = usermodel1.UserId; Address addrmodel = new Address(); addrmodel.UserId = LatestUserId; addrmodel.AddressLine1 = usermodel.AddressLine1; addrmodel.AddressLine2 = usermodel.AddressLine2; addrmodel.Pincode = usermodel.Pincode; dbmodel.Addresses.Add(addrmodel); try { dbmodel.SaveChanges(); } catch (DbEntityValidationException e) { Console.WriteLine(e); } //Country countrymodel = new Country(); //countrymodel.UserId = LatestUserId; //countrymodel.CountryId = usermodel.CountryId; } ModelState.Clear(); ViewBag.SuccessMessage = "Registration Successfull."; return(View("Registration", new UserRecords())); }