Пример #1
0
        public async Task <ActionResult <V1DTO.NutritionInfo> > PostNutritionInfo(V1DTO.NutritionInfo nutritionInfo)
        {
            var bllEntity = _mapper.Map(nutritionInfo);

            _bll.NutritionInfos.Add(bllEntity);
            await _bll.SaveChangesAsync();

            nutritionInfo.Id = bllEntity.Id;

            return(CreatedAtAction("GetNutritionInfo",
                                   new { id = nutritionInfo.Id, version = HttpContext.GetRequestedApiVersion()?.ToString() ?? "0" },
                                   nutritionInfo));
        }
Пример #2
0
        public async Task <IActionResult> PutNutritionInfo(Guid id, V1DTO.NutritionInfo nutritionInfo)
        {
            if (id != nutritionInfo.Id)
            {
                return(BadRequest(new V1DTO.MessageDTO("Id and NutritionInfo.Id do not match")));
            }

            await _bll.NutritionInfos.UpdateAsync(_mapper.Map(nutritionInfo));

            await _bll.SaveChangesAsync();

            return(NoContent());
        }