Exemple #1
0
 public ActionResult Post([FromBody] Item i)
 {
     if (i == null)
     {
         return(BadRequest("Item is null"));
     }
     _itemRepository.createItem(i);
     return(NoContent());
 }
        public ActionResult Post([FromBody] Item i)
        {
            if (i == null)
            {
                return(BadRequest("Item is null"));
            }
            int burn;
            int nr_days = (i.ExpirationDate - DateTime.Today).Days;

            if (nr_days > 0)
            {
                burn = i.Calories / nr_days;
            }
            else
            {
                burn = 0;
            }
            i.Ideal = burn;
            _itemRepository.createItem(i);
            return(NoContent());
        }