public async Task <ReturnValueModel> Update(UpdateItemsDto input) { string strMessage = string.Empty; bool IfSuccess = true; ReturnValueModel model = new ReturnValueModel(); try { var entity = _repository.QueryNoTracking(p => p.ItemType == input.ItemType).FirstOrDefault(); if (entity != null && (input.ItemType != input.OldItemType)) { IfSuccess = false; strMessage = string.Format("收支类型【{0}】 已存在!", input.ItemType); } else { IfSuccess = true; var items = _mapper.Map <BasItems>(input); await _repository.UpdateAsync(items); await _unitOfWork.SaveChangesAsync(); } } catch (System.Exception ex) { IfSuccess = false; strMessage = ex.Message; } model.IfSuccess = IfSuccess; model.Message = strMessage; return(model); }
public async Task <IActionResult> UpdateItem(UpdateItemsDto input) { int UserID = Convert.ToInt32(User.FindFirstValue(ClaimTypes.Sid)); input.CreateDisPlayName = (await _userRepository.FirstOrDefaultAsync(x => x.Id == UserID)).DisPlayName; input.CreateUserID = UserID; var model = await _basIemsService.Update(input); return(Json(model)); }
public async Task <IActionResult> Create(int Id) { UpdateItemsDto model = new UpdateItemsDto(); if (Id > 0) { var item = await _basIemsService.GetItemsEntity(Convert.ToInt32(Id)); model = _mapper.Map(item, model); ViewBag.Id = item.Id; ViewBag.ItemType = item.ItemType; } else { ViewBag.Id = 0; } return(View(model)); }