public JsonResult Create(CreateVM model) { var result = new JsonResultBO(true, "Tạo tài khoản thành công"); try { if (ModelState.IsValid) { if (_appUserService.CheckExistUserName(model.UserName)) { throw new Exception(string.Format("Tài khoản {0} đã tồn tại", model.UserName)); } if (_appUserService.CheckExistEmail(model.Email)) { throw new Exception(string.Format("Email {0} đã được sửa dụng", model.Email)); } var user = new AppUser(); user.UserName = model.UserName; user.FullName = model.FullName; user.PhoneNumber = model.PhoneNumber; user.BirthDay = model.BirthDay; user.Address = model.Address; user.Gender = model.Gender; user.Email = model.Email; user.Avatar = "images/avatars/profile-pic.jpg"; var UserManager = HttpContext.GetOwinContext().GetUserManager <ApplicationUserManager>(); //Kiểm tra thông tin tài khoản var resultUser = UserManager.CreateAsync(user, UserConst.DefaultPassword).Result; if (!resultUser.Succeeded) { throw new Exception(getErrorString(resultUser)); } } } catch (Exception ex) { result.MessageFail(ex.Message); _Ilog.Error("Lỗi tạo mới tài khoản", ex); } return(Json(result)); }