public HospitalHealViewModel(Hospital hospital, IHospitalService hospitalService, IHospitalRepository hospitalRepository, bool showHospitalName = false)
        {
            HospitalID = hospital.CompanyID;

            HealingPrice = (double?)hospital.HealingPrice;

            HealingEnabled = hospital.HealingEnabled && SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen);
            if (HealingEnabled)
            {
                var citizen = SessionHelper.LoggedCitizen;
                var result  = hospitalService.CanHealCitizen(SessionHelper.LoggedCitizen, hospital);
                CanHealYou      = result.isSuccess;
                NoHealingReason = result.ToString("<br/>"); //if there are no errors it will be empty.
                if (CanHealYou)
                {
                    CurrencySymbol = Persistent.Countries.GetCountryCurrency(hospital.Company.Region.Country).Symbol;
                    HealingPrice   = (double?)hospitalRepository.GetHealingPrice(hospital.CompanyID, citizen.ID).Cost;
                }
            }

            if (ShowHospitalName = showHospitalName)
            {
                HospitalName = hospital.Company.Entity.Name;
            }
        }
Пример #2
0
        public ActionResult Heal(int hospitalID)
        {
            var hospital = hospitalRepository.GetById(hospitalID);
            var citizen  = SessionHelper.LoggedCitizen;

            var result = hospitalService.CanHealCitizen(citizen, hospital);

            if (result.IsError)
            {
                return(RedirectBackWithError(result));
            }

            using (var trs = transactionScopeProvider.CreateTransactionScope())
            {
                hospitalService.HealCitizen(citizen, hospital);
                trs.Complete();

                AddSuccess("You have been healed!");
                return(RedirectBack());
            }
        }