public ActionResult Create(RegistrationViewModel objEntity) { RegistrationRepository objRegistrationRepository = new RegistrationRepository(); if (ModelState.IsValid) { objEntity.Status = StatusFlags.Active.GetHashCode(); objEntity.UserTypeId = UserTypes.User.GetHashCode(); objRegistrationRepository.Insert(objEntity); if (objEntity.Result == ResultFlags.Success.GetHashCode()) { this.Flash("success", "Registration created successfully "); //return RedirectToAction("Index"); return RedirectToAction("Login", "User"); } else if (objEntity.Result == ResultFlags.Failure.GetHashCode()) { this.Flash("error", "Failed to create account"); return RedirectToAction("Index"); } else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode()) { this.Flash("warning", "It already exist"); } } return View(objEntity); }
public ActionResult Register(RegistrationViewModel objEntity) { RegistrationRepository objRegistrationRepository = new RegistrationRepository(); string fileName = string.Empty; if (ModelState.IsValid) { #region FileUpload if (objEntity.UploadPhoto != null) { fileName = Guid.NewGuid().ToString() + Path.GetExtension(objEntity.UploadPhoto.FileName); objEntity.PhotoName = fileName; } else { objEntity.PhotoName = string.Empty; } #endregion objEntity.RoleId = (Int16)RoleUserDefinedEnum.User.GetHashCode(); PasswordHelpers.HashedPassword objHashedPassword = PasswordHelpers.Generate(objEntity.Password); objEntity.Password = objHashedPassword.Password; objEntity.PasswordSalt = objHashedPassword.Salt; objEntity.Status = StatusEnum.Active.GetHashCode(); objRegistrationRepository.Insert(objEntity); if (objEntity.Result == ResultFlags.Success.GetHashCode()) { this.Flash("success", "Registration created successfully "); #region FileUpload //file name if (objEntity.PhotoName != null) { string path = Path.Combine(Server.MapPath(ApplicationConstant.UPLOADED_USER_PHOTO_PATH), fileName); // WebImage.Save() objEntity.UploadPhoto.SaveAs(path); } #endregion //return RedirectToAction("Index"); return RedirectToAction("Login", "User"); } else if (objEntity.Result == ResultFlags.Failure.GetHashCode()) { this.Flash("Error", "Failed to create account"); return RedirectToAction("Index"); } else if (objEntity.Result == ResultFlags.Duplicate.GetHashCode()) { this.Flash("Warning", "It already exist"); } } return View(objEntity); }