Beispiel #1
0
        /// <summary>
        /// Local helper method to help regenerate properties neccessary when navigating between actions
        /// </summary>
        /// <typeparam name="TariffViewModel">The type of view model object</typeparam>
        /// <typeparam name="bool">The type of update flag</typeparam>
        /// <param name="source">Old data of new generated properties, set it null will automatically set null all properties other than SelectList items</param>
        /// <param name="update">Boolean value that indicates the view model is going to update or reset. Set true</param>
        /// <returns>New view model data to bind to target view</returns>
        private TariffViewModel GenerateProperties(TariffViewModel source, bool update)
        {
            var productTypeList = service.GetProductTypes().Select(item => new ProductTypeFormViewModel()
            {
                ProdCode    = item.PROD_CODE,
                ProductType = item.PRODUCT_TYPE
            }).AsQueryable();

            var data = source;

            if (!update || data == null)
            {
                data = new TariffViewModel();
            }
            data.MainMenu        = mainMenu;
            data.CurrentMenu     = PageInfo;
            data.IsNotViewer     = CurrentUser.UserRole == Enums.UserRole.Administrator;
            data.ProductTypeList = GenericHelpers <ProductTypeFormViewModel> .GenerateList(productTypeList, item => item.ProdCode, item => item.ProductType);

            data.ShowActionOptions   = data.IsNotViewer;
            data.EditMode            = false;
            data.EnableFormInput     = true;
            data.ViewModel.IsCreator = false;
            data.ViewModel           = this.FormatCurrency(data.ViewModel);
            return(data);
        }
Beispiel #2
0
        public ActionResult Detail(long id)
        {
            if (CurrentUser.UserRole == Enums.UserRole.Viewer)
            {
                AddMessageInfo("Operation not allow", Enums.MessageInfoType.Error);
                return(RedirectToAction("Index"));
            }

            var model             = new ConfigurationViewModel();
            var data              = configService.GetConfigDataByID(id);
            var changeHistoryList = _changesHistoryBll.GetByFormTypeAndFormId(Enums.MenuList.Configuration, id.ToString());
            var typeList          = configService.GetAllType().Select(item => new ConfigurationCreateViewModel()
            {
                ConfigType = item.SYS_REFFERENCES_TYPE1,
                ConfigText = item.SYS_REFFERENCES_TEXT
            });

            try
            {
                model = Mapper.Map <ConfigurationViewModel>(data);
                model.ChangesHistoryList = Mapper.Map <List <ChangesHistoryItemModel> >(changeHistoryList);
                model.TypeList           = GenericHelpers <ConfigurationCreateViewModel> .GenerateList(typeList, item => item.ConfigType, item => item.ConfigText);
            }
            catch (Exception ex)
            {
                AddMessageInfo(ex.Message, Enums.MessageInfoType.Error);
            }

            model.MainMenu    = _mainMenu;
            model.CurrentMenu = PageInfo;
            model.IsNotViewer = (CurrentUser.UserRole != Enums.UserRole.Viewer);

            return(View("Detail", model));
        }
        private SupportDocViewModel GenerateProperties(SupportDocViewModel source, bool update)
        {
            var companyList = service.GetCompanies().Select(item => new CompanyModel()
            {
                Id   = item.BUKRS,
                Name = item.BUTXT
            });

            var data = source;

            if (!update || data == null)
            {
                data = new SupportDocViewModel();
            }

            IEnumerable <Enums.FormList> formTypes = Enum.GetValues(typeof(Enums.FormList)).Cast <Enums.FormList>();

            data.ListForm = from form in formTypes
                            select new SelectListItem
            {
                Text  = EnumHelper.GetDescription((Enum)Enum.Parse(typeof(Enums.FormList), form.ToString())),
                Value = ((int)form).ToString()
            };

            data.MainMenu    = mainMenu;
            data.CurrentMenu = PageInfo;
            data.IsNotViewer = CurrentUser.UserRole == Enums.UserRole.Administrator;
            data.CompanyList = GenericHelpers <CompanyModel> .GenerateList(companyList, item => item.Id, item => item.Name);

            data.ShowActionOptions   = data.IsNotViewer;
            data.EditMode            = false;
            data.EnableFormInput     = true;
            data.ViewModel.IsCreator = false;
            return(data);
        }
Beispiel #4
0
        public ActionResult Create()
        {
            if (CurrentUser.UserRole == Enums.UserRole.Viewer)
            {
                AddMessageInfo("Operation not allow", Enums.MessageInfoType.Error);
                return(RedirectToAction("Index"));
            }

            var model = new ConfigurationCreateViewModel();

            model.MainMenu    = _mainMenu;
            model.CurrentMenu = PageInfo;
            model.IsNotViewer = (CurrentUser.UserRole != Enums.UserRole.Viewer);

            var typeList = configService.GetAllType().Select(item => new ConfigurationCreateViewModel()
            {
                ConfigType = item.SYS_REFFERENCES_TYPE1,
                ConfigText = item.SYS_REFFERENCES_TEXT
            });

            var hintList       = configService.SelectNameByReferenceType("HINT_COMPONENT");
            var selectHintList = from s in hintList
                                 select new SelectListItem
            {
                Value = s.REFF_NAME,
                Text  = s.REFF_NAME
            };
            var nameHintList = new SelectList(selectHintList.GroupBy(p => p.Value).Select(g => g.First()), "Value", "Text");


            var approvalList       = configService.SelectNameByReferenceType("APPROVAL_STATUS");
            var selectApprovalList = from s in approvalList
                                     select new SelectListItem
            {
                Value = s.REFF_NAME,
                Text  = s.REFF_NAME
            };
            var nameApprovalList = new SelectList(selectApprovalList.GroupBy(p => p.Value).Select(g => g.First()), "Value", "Text");

            model.ApprovalList = nameApprovalList;
            model.HintList     = nameHintList;

            var userList = configService.GetAdminAvailable().Select(item => new UserModel()
            {
                UserId   = item.USER_ID,
                FullName = item.NAMA_USER,
            });

            model.TypeList = GenericHelpers <ConfigurationCreateViewModel> .GenerateList(typeList, item => item.ConfigType, item => item.ConfigText);

            model.UserList = userList.ToList();

            return(View("Create", model));
        }
        /// <summary>
        /// Local helper method to help regenerate properties neccessary when navigating between actions
        /// </summary>
        /// <typeparam name="FinanceRatioViewModel">The type of view model object</typeparam>
        /// <typeparam name="bool">The type of update flag</typeparam>
        /// <param name="source">Old data of new generated properties, set it null will automatically set null all properties other than SelectList items</param>
        /// <param name="update">Boolean value that indicates the view model is going to update or reset. Set true</param>
        /// <returns>New view model data to bind to target view</returns>
        private FinanceRatioViewModel GenerateProperties(FinanceRatioViewModel source, bool update)
        {
            var companyList = service.GetCompanies().Select(item => new CompanyModel()
            {
                Id   = item.BUKRS,
                Name = item.BUTXT
            });
            var temp    = 0; // default value
            var span    = Int32.TryParse(ConfigurationManager.AppSettings["YearSpanLength"], out temp) ? temp : 50;
            var periods = new List <int>();

            for (int i = DateTime.Now.Year - span; i < DateTime.Now.Year + span; i++)
            {
                periods.Add(i);
            }
            var yearPeriods = from item in periods
                              select new SelectListItem()
            {
                Value = item.ToString(),
                Text  = item.ToString()
            };
            var data = source;

            if (!update || data == null)
            {
                data = new FinanceRatioViewModel();
            }
            data.MainMenu    = mainMenu;
            data.CurrentMenu = PageInfo;
            data.IsNotViewer = CurrentUser.UserRole == Enums.UserRole.Administrator;
            data.CompanyList = GenericHelpers <CompanyModel> .GenerateList(companyList, item => item.Id, item => item.Name);

            data.YearPeriods = new SelectList(yearPeriods
                                              .GroupBy(item => item.Value)
                                              .Select(group => group.First()), "Value", "Text");

            // set default data
            data.ViewModel.YearPeriod = DateTime.Now.Year;
            data.ShowActionOptions    = data.IsNotViewer;
            data.EditMode             = false;
            data.EnableFormInput      = true;
            data.ViewModel.IsCreator  = false;
            return(data);
        }