/// <inheritdoc/> public async Task <SportNutritionProductImage> UpdateSportNutritionProductImageAsync(int sportNutritionProductImageID, UpdateSportNutritionProductImageRequest updateRequest) { var dbSportNutritionProductImages = await _context.SportNutritionProductImages.Where(c => c.SportNutritionProductImageID == sportNutritionProductImageID).ToArrayAsync(); var dbSportNutritionProductImage = dbSportNutritionProductImages.FirstOrDefault(); if (dbSportNutritionProductImage == null) { throw new RequestedResourceNotFoundException(); } Mapper.Map(updateRequest, dbSportNutritionProductImage); await _context.SaveChangesAsync(); dbSportNutritionProductImages = await _context.SportNutritionProductImages.Where(c => c.SportNutritionProductImageID == sportNutritionProductImageID).ToArrayAsync(); return(dbSportNutritionProductImages.Select(c => Mapper.Map <SportNutritionProductImage>(c)).FirstOrDefault()); }
/// <inheritdoc/> public async Task <SportNutritionProductImage> CreateSportNutritionProductImageAsync(UpdateSportNutritionProductImageRequest createRequest) { var dbSportNutritionProductImage = Mapper.Map <UpdateSportNutritionProductImageRequest, DbSportNutritionProductImage>(createRequest); _context.SportNutritionProductImages.Add(dbSportNutritionProductImage); await _context.SaveChangesAsync(); return(Mapper.Map <SportNutritionProductImage>(dbSportNutritionProductImage)); }