示例#1
0
        // GET: ConfigItems
        public async Task <ActionResult> Index(string environment)
        {
            if (environment == null)
            {
                var configItems        = this.configItemRepository.GetAll();
                var activeEnvironments = await this.clientRepository.GetActiveEnvironments();

                var viewModels = (await configItems).Select(x =>
                {
                    var viewModel      = new ConfigItemViewModel(x);
                    viewModel.IsActive = activeEnvironments.ContainsKey(x.Environment);
                    return(viewModel);
                });

                return(View(viewModels));
            }
            else
            {
                Task <IEnumerable <ConfigItem> > configItems =
                    this.configItemRepository.GetAll(environment);

                Task <bool> isActive = this.clientRepository.IsActive(environment);

                var viewModle = new ConfigsViewModel
                {
                    EnvironmentName = environment,
                    ConfigItems     = await configItems,
                    IsActive        = await isActive,
                };
                return(View("Environment", viewModle));
            }
        }
示例#2
0
        public ViewResult Index()
        {
            ConfigsViewModel model = new ConfigsViewModel();

            model.ListTemplatePrint       = new List <Areas.Administration.Models.SettingViewModel>();
            model.ListSaleSetting         = new List <Areas.Administration.Models.SettingViewModel>();
            model.ListSaleSetting_Prefix  = new List <Areas.Administration.Models.SettingViewModel>();
            model.ListSaleSetting_OrderNo = new List <Areas.Administration.Models.SettingViewModel>();
            model.ListSaleSetting_Manual  = new List <Areas.Administration.Models.SettingViewModel>();

            //settingprint
            var q1 = settingRepository.GetAlls()
                     .Where(item => item.Code == "settingprint")
                     .OrderBy(item => item.Note).ToList();

            AutoMapper.Mapper.Map(q1, model.ListTemplatePrint);

            //salesetting
            var q2 = settingRepository.GetAlls()
                     .Where(item => item.Code == "salesetting")
                     .OrderBy(item => item.Note).ToList();

            AutoMapper.Mapper.Map(q2, model.ListSaleSetting);

            //salesetting_prefix
            var q3 = settingRepository.GetAlls()
                     .Where(item => item.Code == "salesetting_prefix")
                     .OrderBy(item => item.Note).ToList();

            AutoMapper.Mapper.Map(q3, model.ListSaleSetting_Prefix);

            //salesetting_orderno
            var q4 = settingRepository.GetAlls()
                     .Where(item => item.Code == "salesetting_orderno")
                     .OrderBy(item => item.Note).ToList();

            AutoMapper.Mapper.Map(q4, model.ListSaleSetting_OrderNo);

            //salesetting_manual
            var q5 = settingRepository.GetAlls()
                     .Where(item => item.Code == "salesetting_manual")
                     .OrderBy(item => item.Note).ToList();

            AutoMapper.Mapper.Map(q5, model.ListSaleSetting_Manual);

            return(View(model));
        }