示例#1
0
        public IActionResult Contacts(Guid id)
        {
            var viewModel = new HospitalInfoViewModel();

            var hospital = this.hospitalsService.GetHospitalDataById <HospitalInfoViewModel>(null, id.ToString());

            if (hospital == null)
            {
                return(this.RedirectToAction("HttpStatusCodeHandler", "Error", this.NotFound()));
            }

            viewModel.Contact = new Contact
            {
                Phone = hospital.Contact.Phone,
                Email = hospital.Contact.Email,
            };

            viewModel.Location = new Location
            {
                Country           = hospital.Location.Country,
                City              = hospital.Location.City,
                AdressDescription = hospital.Location.AdressDescription,
            };

            return(this.View(viewModel));
        }
        public async Task <bool> InformacionOcupacion()
        {
            info = new HospitalInfoViewModel();

            if (await info.ObtenerOcupacionAPI(hospital.id))
            {
                OcupacionH = info.ObtenerOcupacion();
                reordenarHoras();
                return(true);
            }
            return(false);
        }
        public void SaveHospitalInfo(HospitalInfoViewModel hospital)
        {
            using (var scope = new TransactionScope())
            {
                var hospitalMaster = Entities.FirstOrDefault(w => w.Id == hospital.HospitalId);

                if (hospitalMaster == null)
                {
                    throw new Exception("No hospital found");
                }

                var hospitalContacts = hospitalMaster.HospitalContacts.ToList();
                //var hospitalContacts = _context.Set<HospitalContact>().Where(w => w.HospitalId == hospital.HospitalId).ToList();
                hospitalContacts.ForEach(c => _context.Set <HospitalContact>().Remove(c));

                var workingDays = hospitalMaster.HospitalWorkingDays.ToList();
                //var workingDays = _context.Set<HospitalWorkingDay>().Where(w => w.HospitalId == hospital.HospitalId).ToList();
                workingDays.ForEach(d => _context.Set <HospitalWorkingDay>().Remove(d));

                var hospitalContact = hospital.ContactNo.Split(',')
                                      .Select(s => new HospitalContact {
                    ContactNo = s, IsEmergency = false, HospitalId = hospital.HospitalId
                })
                                      .ToList();

                var emergencyContacts = hospital.EmergencyContact.Split(',')
                                        .Select(s => new HospitalContact {
                    ContactNo = s, IsEmergency = true, HospitalId = hospital.HospitalId
                })
                                        .ToList();

                hospitalContact.AddRange(emergencyContacts);

                hospitalMaster.Name             = hospital.HospitalName;
                hospitalMaster.Email            = hospital.Email;
                hospitalMaster.AddressLine1     = hospital.AddressLine1;
                hospitalMaster.AddressLine2     = hospital.AddressLine2;
                hospitalMaster.WorkingHoursFrom = hospital.WorkingHoursFrom;
                hospitalMaster.WorkingHoursTo   = hospital.WorkingHoursTo;
                hospitalMaster.HospitalContacts.AddRange(hospitalContact);
                hospitalMaster.HospitalWorkingDays.AddRange(hospital.GetHospitalWorkingDaysFromProperties());

                _context.SaveChanges();

                scope.Complete();
            }
        }
        public ActionResult Index(HospitalInfoViewModel model, string create = null)
        {
            try
            {
                _hospitalInfoService.SaveHospitalInfo(model);

                // Clear the cache
                _cacheManager.Remove(CacheKeys.HospitalInfo.ToString());

                SuccessNotification(Resources.SaveSuccess);
            }
            catch (Exception e)
            {
                Logger.log.Error($"Save Hospital: {e.Message}");
                ErrorNotification(Resources.SaveFailed);
            }

            return(RedirectToAction(nameof(Index)));
        }
        public HospitalInfoViewModel GetHospitalById(int hospitalId)
        {
            var hospitalMaster = _hospitalInfoRepository.GetHospitalById(hospitalId);

            var contacts          = hospitalMaster.HospitalContacts.Where(w => !w.IsEmergency).Select(s => s.ContactNo);
            var emergencyContacts = hospitalMaster.HospitalContacts.Where(w => w.IsEmergency).Select(s => s.ContactNo);

            var hospitalInfoViewModel = new HospitalInfoViewModel
            {
                HospitalId       = hospitalMaster.Id,
                HospitalName     = hospitalMaster.Name,
                AddressLine1     = hospitalMaster.AddressLine1,
                AddressLine2     = hospitalMaster.AddressLine2,
                Email            = hospitalMaster.Email,
                WorkingHoursFrom = hospitalMaster.WorkingHoursFrom,
                WorkingHoursTo   = hospitalMaster.WorkingHoursTo,
                ContactNo        = string.Join(", ", contacts),
                EmergencyContact = string.Join(", ", emergencyContacts)
            };

            hospitalInfoViewModel.SetWorkingDaysFromEntity(hospitalMaster.HospitalWorkingDays);

            return(hospitalInfoViewModel);
        }
 public void SaveHospitalInfo(HospitalInfoViewModel hospital)
 {
     _hospitalInfoRepository.SaveHospitalInfo(hospital);
 }