Esempio n. 1
0
 public IActionResult Create(Animals model)
 {
     if (ModelState.IsValid)
     {
         var maxId = catRepository.GetCats().Max(x => x.Id) + 1;
         model.Id = maxId;
         catRepository.AddCat(model);
         return(RedirectToAction("List"));
     }
     return(View(model));
 }
Esempio n. 2
0
        public bool AddCat(string cat)
        {
            Cat deserialize = JsonConvert.DeserializeObject <Cat>(cat);

            if (catsContext.CatExists(deserialize.Name))
            {
                return(false);
            }
            catsContext.AddCat(cat);
            return(true);
        }
Esempio n. 3
0
 public ActionResult <Cat> Post([FromBody] Cat value)
 {
     return(Created("/api/cats/", _catRepo.AddCat(value)));
 }