public async Task <IActionResult> Edit(int id, [Bind("DoctorId,AvailableTime,AvailabilityId")] DoctorAvailability doctorAvailability)
        {
            if (id != doctorAvailability.AvailabilityId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(doctorAvailability);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DoctorAvailabilityExists(doctorAvailability.AvailabilityId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctor, "DoctorId", "DoctorEmail", doctorAvailability.DoctorId);
            return(View(doctorAvailability));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id, [Bind("DoctorName,Salary,DoctorEmail,DoctorId")] Doctor doctor)
        {
            if (id != doctor.DoctorId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(doctor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DoctorExists(doctor.DoctorId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(doctor));
        }
        public async Task <IActionResult> Edit(int id, [Bind("MedicalreportId,ReportType")] MedicalreportType medicalreportType)
        {
            if (id != medicalreportType.MedicalreportId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medicalreportType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicalreportTypeExists(medicalreportType.MedicalreportId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicalreportType));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("NurseName,Salary,NurseEmail,NurseId,DoctorId")] Nurse nurse)
        {
            if (id != nurse.NurseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(nurse);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NurseExists(nurse.NurseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"] = new SelectList(_context.Doctor, "DoctorId", "DoctorEmail", nurse.DoctorId);
            return(View(nurse));
        }
        public async Task <IActionResult> Edit(string id, [Bind("VisitReason,Prescription,Visitid,VisitDate,Visited,PatientId,DoctorId")] VisitRecord visitRecord)
        {
            if (id != visitRecord.Visitid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(visitRecord);
                    await _context.SaveChangesAsync();

                    if (visitRecord.Visited == true)
                    {
                        //Clear appointment once patient visits the doctor
                        int patient_id          = visitRecord.PatientId;
                        var appointment_context = _context.Appointment.Where(a => a.PatientId == patient_id).FirstOrDefault();
                        _context.Appointment.Remove(appointment_context);
                        await _context.SaveChangesAsync();

                        var record = new Billing {
                            BillingAmount = 50, BillingDate = DateTime.UtcNow, PatientId = visitRecord.PatientId, Paid = false
                        };
                        _context.Add(record);
                        await _context.SaveChangesAsync();

                        //return RedirectToAction("Create", "Billings");
                        return(RedirectToAction("Index", "VisitRecords"));
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VisitRecordExists(visitRecord.Visitid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"]  = new SelectList(_context.Doctor, "DoctorId", "DoctorEmail", visitRecord.DoctorId);
            ViewData["PatientId"] = new SelectList(_context.Patient, "PatientId", "PatientEmail", visitRecord.PatientId);
            return(View(visitRecord));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ApptId,ApptDate,AppointmentReason,PatientEmail,PatientId,VisitRecord,DoctorId")] Appointment appointment)
        {
            if (id != appointment.ApptId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (appointment.VisitRecord == true)
                    {
                        var addtovisit = new VisitRecord {
                            DoctorId = appointment.DoctorId, PatientId = (int)appointment.PatientId, Prescription = "N/A", VisitDate = appointment.ApptDate, VisitReason = appointment.AppointmentReason, Visited = false, Visitid = Guid.NewGuid().ToString()
                        };
                        _context.Add(addtovisit);
                        await _context.SaveChangesAsync();
                    }
                    _context.Update(appointment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AppointmentExists(appointment.ApptId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DoctorId"]  = new SelectList(_context.Doctor, "DoctorId", "DoctorEmail", appointment.DoctorId);
            ViewData["PatientId"] = new SelectList(_context.Patient, "PatientId", "PatientEmail", appointment.PatientId);
            return(View(appointment));
        }
Пример #7
0
        public async Task <IActionResult> Edit(int id, [Bind("PatientName,PatientEmail,PatientAddress,Phone,Ssn,Weight,Height,Insurance,Bloodpressure,Pulse,AppointmentMisused,PatientId,Allergy")] Patient patient)
        {
            if (id != patient.PatientId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(patient);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PatientExists(patient.PatientId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                if (User.IsInRole("Doctor") || User.IsInRole("Nurse"))
                {
                    return(RedirectToAction("Index", "VisitRecords"));
                }
                else
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(patient));
        }