Ejemplo n.º 1
0
        public ActionResult EditSpecialties(int id)
        {
            var doctor    = _doctorRepository.Get(id);
            var viewModel = new DoctorSpecialtiesViewModel()
            {
                DoctorId    = doctor.Id,
                FullName    = doctor.FullName,
                Specialties = doctor.Specialties
            };

            // Extend the Specialties to a total of 6 for data entry
            while (viewModel.Specialties.Count < 6)
            {
                viewModel.Specialties.Add(new DoctorSpecialty());
            }

            if (Session["SpecialtyItems"] == null)
            {
                var items = _specialtyRepository.Search("")
                            .Select(s => new
                {
                    Text  = s.SpecialtyName,
                    Value = s.Id
                })
                            .ToList();
                Session["SpecialtyItems"] = items;
            }
            ViewBag.SpecialtyItems = Session["SpecialtyItems"];

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        internal bool SaveDoctorSpecialties(DoctorSpecialtiesViewModel viewModel)
        {
            // First, delete all specialties assigned to this doctor and then
            // add back in the ones that are not marked as Remove
            try
            {
                var sql = $"delete from hlc_DoctorSpecialty where DoctorId={viewModel.DoctorId}";
                ExecuteSql(sql);

                foreach (var spec in viewModel.Specialties)
                {
                    if (!spec.Remove && spec.SpecialtyId != 0)
                    {
                        spec.DoctorId = viewModel.DoctorId;
                        spec.Id       = 0;
                        var newId = Connection.Insert(spec);
                        spec.Id = (int)newId;
                    }
                }
                GetSelectListAnesthesiologists(true);
                return(true);
            }
            catch (Exception ex)
            {
                LogException(ex, viewModel);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public ActionResult EditSpecialties(DoctorSpecialtiesViewModel viewModel)
        {
            //if (!ModelState.IsValid)
            //{
            //    ViewBag.SpecialtyItems = Session["SpecialtyItems"];
            //    return View(viewModel);
            //}

            // Pass to repository to update
            _doctorRepository.SaveDoctorSpecialties(viewModel);

            return(RedirectToAction("View", new { id = viewModel.DoctorId }));
        }