コード例 #1
0
        public async Task <IActionResult> CreateUpdate(int?id)
        {
            ViewBag.Lang = Lng;

            var places = _commonUtils.PopulateCitiesList();

            if (id == null)
            {
                return(View(new HospitalViewModel {
                    listPlaces = places
                }));
            }

            var hospital = await _hospitalService.GetHospitalByIdAsync((int)id);

            if (hospital == null)
            {
                throw new EntityNotFoundException("Hospital");
            }

            var hospitalViewModel = new HospitalViewModel
            {
                Id                     = hospital.Id,
                Name                   = hospital.Name,
                Name_Ku                = hospital.Name_Ku,
                Name_Ar                = hospital.Name_Ar,
                Description            = hospital.Description,
                Description_Ku         = hospital.Description_Ku,
                Description_Ar         = hospital.Description_Ar,
                CityId                 = hospital.CityId,
                Address                = hospital.Address,
                Address_Ku             = hospital.Address_Ku,
                Address_Ar             = hospital.Address_Ar,
                FinalBookMessage       = hospital.FinalBookMessage,
                FinalBookMessage_Ku    = hospital.FinalBookMessage_Ku,
                FinalBookMessage_Ar    = hospital.FinalBookMessage_Ar,
                FinalBookSMSMessage    = hospital.FinalBookSMSMessage,
                FinalBookSMSMessage_Ku = hospital.FinalBookSMSMessage_Ku,
                FinalBookSMSMessage_Ar = hospital.FinalBookSMSMessage_Ar,
                GoogleMap_lat          = hospital.Location?.Y.ToString(),
                GoogleMap_lng          = hospital.Location?.X.ToString(),
                listPlaces             = places,
                Logo                   = hospital.Logo
            };

            if (!string.IsNullOrEmpty(hospitalViewModel.Logo))
            {
                ViewBag.LogoPreview = "<img src=" + hospitalViewModel.Logo + " alt=\"Logo\">";
            }

            return(View(hospitalViewModel));
        }