public ActionResult ManageAccount(TeacherManageAccountViewModel model, HttpPostedFileBase imgfile) { //var manager = new UserManager(); var user = UserManager.FindById(User.Identity.GetUserId()); var teacher = db.Instructors.Where(c => c.UserId == user.Id).SingleOrDefault(); string path = uploadingfile(imgfile); if (path.Equals("-1")) { ViewBag.error = "Image could not be uploaded"; } else { var token = UserManager.GeneratePasswordResetToken(user.Id); UserManager.ResetPassword(user.Id, token, model.NewPassword); teacher.FirstName = model.Teacher.FirstName; teacher.LastName = model.Teacher.LastName; teacher.UserName = model.Teacher.UserName; teacher.UserRole = "Teacher"; teacher.Contact = model.Teacher.Contact; teacher.Password = model.NewPassword; teacher.Email = model.Teacher.Email; teacher.UserId = model.Teacher.UserId; teacher.Detail = model.Teacher.Detail; teacher.Specialization = model.Teacher.Specialization; teacher.ImageUrl = model.Teacher.ImageUrl; db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult ManageAccount() { var user = UserManager.FindById(User.Identity.GetUserId()); var teacher = db.Instructors.Where(c => c.UserId == user.Id).SingleOrDefault(); var collection = new TeacherManageAccountViewModel { Teacher = db.Instructors.Where(c => c.UserId == user.Id).SingleOrDefault(), NewPassword = null, OldPassword = teacher.Password, ConfirmPassword = null }; return(View(collection)); }