public IHttpActionResult SearchByProductID(int id) { if (id <= 0) { return(BadRequest("Please enter valid customer id")); } using (var studententity = new WebAPI_DemoEntities()) { var studentdata = studententity.Students.Where(x => x.Id == id).FirstOrDefault(); return(Ok(studententity)); } }
public IHttpActionResult DeleteCustomer(int id) { if (id <= 0) { return(BadRequest("Please enter valid customer id")); } using (var customerEntity = new WebAPI_DemoEntities()) { var customer = customerEntity.Students.Where(x => x.Id == id).FirstOrDefault(); customerEntity.Entry(customer).State = System.Data.Entity.EntityState.Deleted; } return(Ok()); }
public StudentService() { this._DemoEntities = new WebAPI_DemoEntities(); }
public StudentController() { _DemoEntities = new WebAPI_DemoEntities(); _studentService = new StudentService(); }