Example #1
0
        public HttpResponseMessage PutPatient(int id, PatientDetailDto patientdto)
        {
            Patient patient = new Patient()
            {
                Id               = patientdto.Id,
                Name             = patientdto.Name,
                Age              = patientdto.Age,
                Gender           = patientdto.Gender,
                Weight           = patientdto.Weight,
                DOB              = patientdto.DOB,
                ConsultingDoctor = patientdto.ConsultingDoctor,
                Disease          = patientdto.Disease,
                Contact          = patientdto.Contact,
                RegistrationFee  = patientdto.RegistrationFee,
                LastVisit        = patientdto.LastVisit,
                StatusFlag       = 0
            };


            if (!PatientExists(id))
            {
                return(new HttpResponseMessage(HttpStatusCode.NotFound));
            }
            db.Entry(patient).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, patient));
        }
        public async Task <IHttpActionResult> PutDoctor(int id, Doctor doctor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != doctor.Id)
            {
                return(BadRequest());
            }

            db.Entry(doctor).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DoctorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #3
0
 public ActionResult Edit(TreatmentDetail treatmentDetail)
 {
     if (Session["UserEmail"] != null && Session["UserRole"].ToString() == "Doctor")
     {
         if (ModelState.IsValid)
         {
             db.Entry(treatmentDetail).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.AppointmentId = new SelectList(db.AppointmentDetails, "AppointmentId", "DiseaseInfo", treatmentDetail.AppointmentId);
         ViewBag.PatientId     = new SelectList(db.PatientDetails, "Patient_Id", "Name", treatmentDetail.PatientId);
         return(View(treatmentDetail));
     }
     Response.Write("<script>alert('Please Login')</script>");
     FormsAuthentication.SignOut();
     Session.Clear();
     return(RedirectToAction("SignIn", "Auth"));
 }