public ActionResult Get([FromQuery] String species)
        {
            var db      = new SafariHWContext();
            var results = db.SafariVacation.Where(w => w.Species.Contains(species));


            //return all species where 'r' is included
            return(Ok(results));
        }
Exemple #2
0
        public ActionResult <SafariVacation> Delete(int animalId)
        {
            var db     = new SafariHWContext();
            var animal = db.SafariVacation.FirstOrDefault(f => f.Id == animalId);

            db.SafariVacation.Remove(animal);
            db.SaveChanges();

            return(animal);
        }
Exemple #3
0
        public ActionResult <SafariVacation> Post([FromBody] SafariVacation seenAnimals)

        {
            var db = new SafariHWContext();

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

            return(seenAnimals);
        }
Exemple #4
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 }));
            }
        }
Exemple #5
0
        public IEnumerable <SafariVacation> GetByLocation(string location)
        {
            var db = new SafariHWContext();

            return(db.SafariVacation.Where(w => w.LocationOfLastSeen.ToLower() == location.ToLower()));
        }
Exemple #6
0
        public IEnumerable <Models.SafariVacation> Get()
        {
            var db = new SafariHWContext();

            return(db.SafariVacation);
        }