public JsonResult Create(MenuDto model) { string errs = GetModelStateError(); if (!string.IsNullOrEmpty(errs)) { return(Json(new OperateMessage <string>(OperateResult.Fail, true, errs))); } bool IsSucceed = _MenuAppService.Create(new MenuDto() { ID = Guid.NewGuid(), Code = model.Code, CreateTime = DateTime.Now, CreatorID = _currUser.ID, LastUpdateTime = DateTime.Now, LastUpdateUserID = _currUser.ID, Icon = model.Icon, IsTopMenu = model.IsTopMenu, Name = model.Name, ParentId = model.ParentId, Remarks = model.Remarks, SerialNumber = model.SerialNumber, Type = model.Type, Url = model.Url, }); if (IsSucceed) { return(Json(new OperateMessage <string>("/Menu/Index"))); } return(Json(new OperateMessage <string>(IsSucceed ? OperateResult.Success : OperateResult.Fail, true, IsSucceed ? "添加成功!" : "添加失败!"))); }
/// <summary> /// 新增或编辑功能 /// </summary> /// <param name="dto"></param> /// <returns></returns> public IActionResult Edit(MenuDto dto) { if (!ModelState.IsValid) { return(Json(new { Result = "Faild", Message = GetModelStateError() })); } if (dto.ID != Guid.Empty ? _menuAppService.Edit(dto) : _menuAppService.Create(dto)) { return(Json(new { Result = "Success" })); } return(Json(new { Result = "Faild" })); }