예제 #1
0
        void SetViewData(AppointmentViewModel model)
        {
            var cachedStatuses = AppDomain.CurrentDomain.GetData("appointmentStatuses") as List <AppointmentStatusViewModel>;

            if (cachedStatuses == null)
            {
                cachedStatuses = _helperService.GetStatuses();
                AppDomain.CurrentDomain.SetData("appointmentStatuses", cachedStatuses);
            }
            ViewBag.StatusId = new SelectList(cachedStatuses, "Id", "Name", model.StatusId);

            var cachedTypes = AppDomain.CurrentDomain.GetData("appointmentTypes") as List <AppointmentTypeViewModel>;

            if (cachedTypes == null)
            {
                cachedTypes = _helperService.GetTypes();
                AppDomain.CurrentDomain.SetData("appointmentTypes", cachedTypes);
            }
            ViewBag.TypeId = new SelectList(cachedTypes, "Id", "Name", model.TypeId);

            ViewBag.Gender = new SelectList(Enum.GetValues(typeof(Genders)).Cast <Genders>().Select(e => new SelectListItem
            {
                Text  = e.ToString(),
                Value = ((char)e).ToString()
            }), "Value", "Text", model.Gender);

            var cachedCountries = AppDomain.CurrentDomain.GetData("countries") as List <CountryViewModel>;

            if (cachedCountries == null)
            {
                cachedCountries = _helperService.GetCountries();
                AppDomain.CurrentDomain.SetData("countries", cachedCountries);
            }

            ViewBag.CountryId = new SelectList(cachedCountries, "Id", "Name", model.CountryId);
        }