Пример #1
0
        public ActionResult <SafariVacation> Post([FromBody] SafariVacation seenAnimals)

        {
            var db = new SafariHWContext();

            db.SafariVacation.Add(seenAnimals);
            db.SaveChanges();

            return(seenAnimals);
        }
Пример #2
0
        public ActionResult <SafariVacation> Put([FromRoute] int id, [FromBody] SafariVacation updatedData)
        {
            var db     = new SafariHWContext();
            var animal = db.SafariVacation.FirstOrDefault(f => f.Id == id);

            if (animal != null)
            {
                // update the values
                animal.CountOfTimesSeen   = updatedData.CountOfTimesSeen;
                animal.Species            = updatedData.Species;
                animal.LocationOfLastSeen = updatedData.LocationOfLastSeen;
                db.SaveChanges();
                return(animal);
            }
            else
            {
                return(NotFound(new { id, updatedData }));
            }
        }