Пример #1
0
 public IActionResult Post([FromBody] Recipe recipe)
 {
     if (recipe.Id == Guid.Empty)
     {
         recipe.ModifyDate = DateTime.Now;
         return(new ObjectResult(_repository.AddEntity <Recipe>(recipe)));
     }
     else
     {
         var existingOne = _repository.GetEntity <Recipe>(recipe.Id);
         existingOne.Name     = recipe.Name;
         existingOne.Comments = recipe.Comments;
         _repository.UpdateEntity <Recipe>(existingOne);
         return(new ObjectResult(existingOne));
     }
 }