public async Task <HeatingTypeForReturnDto> Update(HeatingTypeForCreationDto updateDto) { var checkById = await heatingTypeDal.GetAsync(x => x.Id == updateDto.Id); if (checkById == null) { throw new RestException(HttpStatusCode.BadRequest, new { NotFound = Messages.NotFound }); } var mapForUpdate = mapper.Map(updateDto, checkById); await heatingTypeDal.Update(mapForUpdate); return(mapper.Map <HeatingType, HeatingTypeForReturnDto>(mapForUpdate)); }
public async Task <HeatingTypeForReturnDto> Create(HeatingTypeForCreationDto createDto) { var checkByName = await heatingTypeDal.GetAsync(x => x.Name.ToLower() == createDto.Name.ToLower()); if (checkByName != null) { throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.AlreadyExist }); } var mapForCreate = mapper.Map <HeatingType>(createDto); var saveToDb = await heatingTypeDal.Add(mapForCreate); var mapForReturn = mapper.Map <HeatingType, HeatingTypeForReturnDto>(saveToDb); return(mapForReturn); }
public async Task <ActionResult <HeatingTypeForReturnDto> > Update(HeatingTypeForCreationDto updateDto) { return(await heatingTypeService.Update(updateDto)); }