public async Task <IActionResult> Create([Bind("ID,FirstName,MiddleName,LastName")] Doctor doctor,
                                                 string[] selectedOptions, List <IFormFile> theFiles)
        {
            try
            {
                UpdateDoctorSpecialties(selectedOptions, doctor);
                if (ModelState.IsValid)
                {
                    await AddDocumentsAsync(doctor, theFiles);

                    _context.Add(doctor);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator.");
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            //Validation Error so give the user another chance.
            PopulateAssignedSpecialtyData(doctor);
            return(View(doctor));
        }
        public async Task <IActionResult> Create([Bind("ID,TrialName")] MedicalTrial medicalTrial)
        {
            if (ModelState.IsValid)
            {
                _context.Add(medicalTrial);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(medicalTrial));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("ID,OHIP,FirstName,MiddleName,LastName,DOB,ExpYrVisits,Phone,eMail,MedicalTrialID,DoctorID")] Patient patient,
                                                 string[] selectedOptions, IFormFile thePicture)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "Patients");

            try
            {
                //Add the selected conditions
                if (selectedOptions != null)
                {
                    foreach (var condition in selectedOptions)
                    {
                        var conditionToAdd = new PatientCondition {
                            PatientID = patient.ID, ConditionID = int.Parse(condition)
                        };
                        patient.PatientConditions.Add(conditionToAdd);
                    }
                }

                if (ModelState.IsValid)
                {
                    await AddPicture(patient, thePicture);

                    _context.Add(patient);
                    await _context.SaveChangesAsync();

                    //Send on to add appointments
                    return(RedirectToAction("Index", "PatientAppt", new { PatientID = patient.ID }));
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                ModelState.AddModelError("", "Unable to save changes after multiple attempts. Try again, and if the problem persists, see your system administrator.");
            }
            catch (DbUpdateException dex)
            {
                if (dex.GetBaseException().Message.Contains("UNIQUE constraint failed: Patients.OHIP"))
                {
                    ModelState.AddModelError("OHIP", "Unable to save changes. Remember, you cannot have duplicate OHIP numbers.");
                }
                else
                {
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
                }
            }

            //Validaiton Error so give the user another chance.
            PopulateAssignedConditionData(patient);
            PopulateDropDownLists(patient);
            return(View(patient));
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("ID,Notes,appDate,extraFee,PatientID,ApptReasonID")] Appointment appointment)
        {
            if (ModelState.IsValid)
            {
                _context.Add(appointment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApptReasonID"] = new SelectList(_context.ApptReasons, "ID", "ReasonName", appointment.ApptReasonID);
            ViewData["PatientID"]    = new SelectList(_context.Patients, "ID", "FirstName", appointment.PatientID);
            return(View(appointment));
        }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("ID,SpecialtyName")] Specialty specialty)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(specialty);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Lookups", new { Tab = "SpecialtiesTab" }));
                }
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return(View(specialty));
        }
        public async Task <IActionResult> Create([Bind("FirstName,LastName,Phone,FavouriteIceCream,Email")] Employee employee)
        {
            employee.Email = User.Identity.Name;
            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(employee);
                    await _context.SaveChangesAsync();

                    UpdateUserNameCookie(employee.FullName);
                    return(RedirectToAction(nameof(Details)));
                }
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            return(View(employee));
        }
Exemple #7
0
        public async Task <IActionResult> Add([Bind("ID,Notes,appDate,extraFee,PatientID,ApptReasonID")] Appointment appointment, string PatientName)
        {
            //Get the URL with the last filter, sort and page parameters
            ViewData["returnURL"] = MaintainURL.ReturnURL(HttpContext, "PatientAppt");

            try
            {
                if (ModelState.IsValid)
                {
                    _context.Add(appointment);
                    await _context.SaveChangesAsync();

                    return(Redirect(ViewData["returnURL"].ToString()));
                }
            }
            catch (DbUpdateException)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }

            PopulateDropDownLists(appointment);
            ViewData["PatientName"] = PatientName;
            return(View(appointment));
        }