示例#1
0
        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));
            }
        }
示例#2
0
        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());
        }
示例#3
0
 public StudentService()
 {
     this._DemoEntities = new WebAPI_DemoEntities();
 }
示例#4
0
 public StudentController()
 {
     _DemoEntities   = new WebAPI_DemoEntities();
     _studentService = new StudentService();
 }