コード例 #1
0
        /// <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());
        }
コード例 #2
0
        /// <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));
        }