public async Task <IActionResult> EditAquarium([FromRoute] int aquariumId, [FromBody] EditAquariumRequest request) { var response = await _aquariumService.EditAquariumAsync(aquariumId, request); return(SendResponse(response)); }
public async Task <ServiceResponse <GetAquariumResponse> > EditAquariumAsync(int aquariumId, EditAquariumRequest request) { var aquarium = await GetEntityByIdAsync <Aquarium>(aquariumId); aquarium.Width = request.Width != 0 ? request.Width : aquarium.Width; aquarium.Height = request.Height != 0 ? request.Height : aquarium.Height; aquarium.Capacity = request.Capacity != 0 ? request.Capacity : aquarium.Capacity; aquarium.FoodMaximalAmount = request.FoodMaximalAmount != 0 ? request.FoodMaximalAmount : aquarium.FoodMaximalAmount; await SaveChangesAsync(); var response = Mapper.Map <Aquarium, GetAquariumResponse>(aquarium); return(new ServiceResponse <GetAquariumResponse>(HttpStatusCode.OK, response)); }