public async Task <VehicleGearTypeForReturnDto> Update(VehicleGearTypeForCreationDto updateDto) { var checkById = await vehicleGearTypeDal.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 vehicleGearTypeDal.Update(mapForUpdate); return(mapper.Map <VehicleGearType, VehicleGearTypeForReturnDto>(mapForUpdate)); }
public async Task <VehicleGearTypeForReturnDto> Create(VehicleGearTypeForCreationDto createDto) { var checkByName = await vehicleGearTypeDal.GetAsync(x => x.Name.ToLower() == createDto.Name.ToLower()); if (checkByName != null) { throw new RestException(HttpStatusCode.BadRequest, new { AlreadyExist = Messages.AlreadyExist }); } var mapForCreate = mapper.Map <VehicleGearType>(createDto); var saveToDb = await vehicleGearTypeDal.Add(mapForCreate); var mapForReturn = mapper.Map <VehicleGearType, VehicleGearTypeForReturnDto>(saveToDb); return(mapForReturn); }
public async Task <ActionResult <VehicleGearTypeForReturnDto> > Update(VehicleGearTypeForCreationDto updateDto) { return(await vehicleGearTypeService.Update(updateDto)); }