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)); }
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); }
public ActionResult <SafariVacation> Post([FromBody] SafariVacation seenAnimals) { var db = new SafariHWContext(); db.SafariVacation.Add(seenAnimals); db.SaveChanges(); return(seenAnimals); }
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 })); } }
public IEnumerable <SafariVacation> GetByLocation(string location) { var db = new SafariHWContext(); return(db.SafariVacation.Where(w => w.LocationOfLastSeen.ToLower() == location.ToLower())); }
public IEnumerable <Models.SafariVacation> Get() { var db = new SafariHWContext(); return(db.SafariVacation); }