public async Task <IResult> Add(UserDto userDto) { var repositoryResult = await _userServices.AddAsync(userDto); var result = ResponseHandler.GetResult(repositoryResult); return(result); }
public async Task <IActionResult> Add(UserViewModel userViewModel) { if (ModelState.IsValid) { var user = await _userServices.AddAsync(userViewModel); if (user) { ViewBag.StoreId = new SelectList(_storeServices.GetStores(), "Id", "StoreName", userViewModel.StoreId); TempData["Succces"] = _commonLocalizer.GetLocalizedHtmlString("msg_AddSuccess").ToString(); return(RedirectToAction("Index")); } ViewData["Error"] = _commonLocalizer.GetLocalizedHtmlString("err_AddUserFailure"); ViewBag.StoreId = new SelectList(_storeServices.GetStores(), "Id", "StoreName", userViewModel.StoreId); return(View(userViewModel)); } ViewBag.StoreId = new SelectList(_storeServices.GetStores(), "Id", "StoreName", userViewModel.StoreId); Log.Error("Add User Error"); return(View(userViewModel)); }
public async Task <ApiResult <string> > Add([FromBody] UserEditWebModel model) { var r = new ApiResult <string>(); var isNew = await _userServices.GetEntity(t => t.UserName.Equals(model.UserName)) == null; if (!isNew) { r.status = 400; r.msg = "账号已存在"; return(r); } try { r.status = await _userServices.AddAsync(new User(model.UserName, MD5Helper.MD5Encrypt32(model.Password))) > 0 ? 200 : 400; r.msg = r.status == 200 ? "添加成功" : "添加失败"; } catch (Exception ex) { r.status = 500; r.msg = ex.Message; } return(r); }