Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        public ActionResult Create(UserDataModel user)
        {
            UserBO.Create(user);

            return RedirectToAction("Index");
        }