//
        // GET: /MemberHospital/Add
        public ActionResult Add()
        {
            try
            {
                var memberZones = SelectListItemExtension.PopulateDropdownList(_db.MemberZones.ToList<MemberZone>(), "Id", "ZoneName").ToList();

                var memberHospitalViewModel = new MemberHospitalViewModel { ddlMemberZones = memberZones };

                return PartialView("_Add", memberHospitalViewModel);
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return RedirectToAction("Index", "MemberHospital");
            }
        }
        public ActionResult Add(MemberHospitalViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var memberHospital = new MemberHospital { Id = viewModel.Id, HospitalName = viewModel.HospitalName, Address = viewModel.Address, LocationX = viewModel.LocationX, LocationY = viewModel.LocationY, MemberZoneId = viewModel.MemberZoneId };

                    _db.MemberHospitals.Add(memberHospital);
                    _db.SaveChanges();

                    return Content(Boolean.TrueString);
                }

                return Content(ExceptionHelper.ModelStateErrorFormat(ModelState));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return Content("Sorry! Unable to add this member hospital.");
            }
        }
        //
        // GET: /MemberHospital/Delete/By ID
        public ActionResult Delete(int id)
        {
            try
            {
                var memberHospital = _db.MemberHospitals.Find(id);
                if (memberHospital != null)
                {
                    var memberHospitalViewModel = new MemberHospitalViewModel { Id = memberHospital.Id, HospitalName = memberHospital.HospitalName, Address = memberHospital.Address, LocationX = memberHospital.LocationX, LocationY = memberHospital.LocationY };

                    return PartialView("_Delete", memberHospitalViewModel);
                }
                else
                {
                    return RedirectToAction("Index", "MemberHospital");
                }

            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return RedirectToAction("Index", "MemberHospital");
            }
        }
        //
        // GET: /MemberHospital/Edit/By ID
        public ActionResult Edit(int id)
        {
            try
            {
                var memberHospital = _db.MemberHospitals.Find(id);
                if (memberHospital != null)
                {
                    var memberZones = SelectListItemExtension.PopulateDropdownList(_db.MemberZones.ToList<MemberZone>(), "Id", "ZoneName", isEdit: true, selectedValue: memberHospital != null ? memberHospital.MemberZoneId.ToString() : "0").ToList();

                    var memberHospitalViewModel = new MemberHospitalViewModel { Id = memberHospital.Id, HospitalName = memberHospital.HospitalName, Address = memberHospital.Address, LocationX = memberHospital.LocationX, LocationY = memberHospital.LocationY, MemberZoneId = memberHospital.MemberZoneId, ddlMemberZones = memberZones };

                    return PartialView("_Edit", memberHospitalViewModel);
                }
                else
                {
                    return RedirectToAction("Index", "MemberHospital");
                }

            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return RedirectToAction("Index", "MemberHospital");
            }
        }