public ActionResult Create(RegisterUserViewModel vm) { if (ModelState.IsValid) { var sha1 = new SHA1CryptoServiceProvider(); var data = Encoding.ASCII.GetBytes(vm.Password); var encrypted = sha1.ComputeHash(data); var password = Encoding.ASCII.GetString(encrypted); var user = new User { Id = Guid.NewGuid(), Name = vm.Name, Email = vm.Email, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, Password = password }; var result = _userService.Create(user); if (result.HasSucceeded) { return(RedirectToAction("Index")); } else { return(HttpNotFound()); } } return(View(vm)); }
public ActionResult Create(UserModel model) { if (Validate(model)) { model.Avatar = model.Gender ? "/Content/img/avatar5.png" : "/Content/img/avatar3.png"; DateTime date; if (!DateTime.TryParseExact(model.DateOfBirth, "dd/MM/yyyy", new CultureInfo("en-US"), DateTimeStyles.None, out date)) { date = DateTime.Now; } UserBO.Create(model.UserName, EncryptUtils.Encrypt(model.Password), model.FirstName, model.LastName, model.Address, date, model.Gender, model.DepartmentId, model.Email, model.Mission, model.Avatar, true, false, model.IsManager, DateTime.Now, DateTime.Now, CurrentUser.Id, CurrentUser.Id); return(RedirectToAction("Index")); } var departments = DepartmentBO.GetAll(); ViewBag.Department = departments; return(View(model)); }
public ActionResult Create(UserDataModel user) { UserBO.Create(user); return RedirectToAction("Index"); }