public async Task <UnitDto> UpdateUnitAsync(UpdateUnitInput input) { var entity = await _menuRepository.GetAsync(input.Id); ObjectMapper.Map(input, entity); entity = await _menuRepository.UpdateAsync(entity); await CurrentUnitOfWork.SaveChangesAsync(); return(ObjectMapper.Map <UnitDto>(entity)); }
public OutputBase UpdateUnit(UpdateUnitInput input) { if (_unitRepository.Query(q => q.Any(u => u.Name == input.Name && u.Id != input.Id))) { return(new OutputBase { Message = "A unit with the same name already exists", Success = false }); } _unitRepository.Update(Mapper.Map <Unit>(input)); return(new OutputBase { Message = "Unit updated", Success = true }); }
public async Task <UnitDto> UpdateUnit([FromBody] UpdateUnitInput input) { return(await _UnitAppService.UpdateUnitAsync(input)); }