///////////////////////////////////// // Delete - Delete school data based on Id public IHttpActionResult Delete(int id) { if (id <= 0) { return(BadRequest("Invalid enter valid school id")); } using (var x = new TestSHEntities()) { var school = x.Schools .Where(c => c.RawID == id) .FirstOrDefault(); x.Entry(school).State = System.Data.Entity.EntityState.Deleted; x.SaveChanges(); } return(Ok()); }
///////////////////////////////////// // POST - Insert new Record public IHttpActionResult PostNewSchool(SchoolViewModel school) { if (!ModelState.IsValid) { return(BadRequest("Invalid Data. Please Check again")); } using (var x = new TestSHEntities()) { x.Schools.Add(new School() { //RawID = c.RawID, SchoolID = school.SchoolID, School_Name = school.School_Name, City = school.City, Directorate = school.Directorate, Lat = school.Lat, Long = school.Long }); x.SaveChanges(); } return(Ok()); }