Ejemplo n.º 1
0
        // DELETE api/<controller>/5
        public HttpResponseMessage Delete(int id)
        {
            doctorBLL DoctorBLL = new doctorBLL();
            //return DoctorBLL.GetbyId(id);
            doctorVM doctorinfo = DoctorBLL.GetbyId(id);


            // db.EmployeeInfoes.Remove(doctorinfo);


            if (doctorinfo == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            try
            {
                DoctorBLL.Delete(id);
                //  db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, doctorinfo));
        }
        public bool Create(doctorVM obj)
        {
            var           doctorMap = Mapper.Map <doctorVM, doctor>(obj);
            TestyEntities _db       = new TestyEntities();

            _db.doctors.Add(doctorMap);

            if (_db.SaveChanges() == 0)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
 // POST api/<controller>
 public HttpResponseMessage PostDoctorInfo(doctorVM doctorinfo)
 {
     if (ModelState.IsValid)
     {
         BLL.doctorBLL grouppermissions = new BLL.doctorBLL();
         grouppermissions.Create(doctorinfo);
         HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, doctorinfo);
         response.Headers.Location = new Uri(Url.Link("DoctorsApi", new { id = doctorinfo.id }));
         return(response);
     }
     else
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest));
     }
 }
        public bool Update(doctorVM obj)
        {
            var _db    = new TestyEntities();
            var doctor = _db.doctors.Where(tem => tem.id == obj.id && tem.user_id == obj.user_id).FirstOrDefault();

            if (doctor != null)
            {
                doctor.address = obj.address;
                //doctor.created_date = obj.created_date;
                doctor.email = obj.email;
                doctor.phone = obj.phone;

                //_db.doctors.Add(doctor);
                if (_db.SaveChanges() == 1)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
        // PUT api/<controller>/5
        public HttpResponseMessage PutDoctorInfo(int id, doctorVM doc)
        {
            if (ModelState.IsValid)
            {
                // db.Entry(doctorinfo).State = EntityState.Modified;

                try
                {
                    BLL.doctorBLL grouppermissions = new BLL.doctorBLL();
                    grouppermissions.Update(doc);
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }