コード例 #1
0
        /*The MVC Framework will call the BindModel method when it wants an instance of the model type that the binder supports.
         * The parameters to the BindModel method are a ControllerContext object that you can use to get details of the
         *  current request and a ModelBindingContext object, which provides details of the model object that is sought, as well
         *  as access to the rest of the model binding facilities in the MVC application
         *  Model => Returns the model object passed to the UpdateModel method if binding has been invoked manually
         *  ModelName => Returns the name of the model that is being bound
         *  ModelType  => Returns the type of the model that is being created
         *  ValueProvider  => Returns an IValueProvider implementation that can be used to get data values from the request
         */
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var form = controllerContext.HttpContext.Request.Form;

            //from form value provider
            if (form.Count > 0)
            {
                InputMenuViewModel menuForm = new InputMenuViewModel {
                    ReportPeriod   = DateTime.Parse(form.Get("ReportPeriod")),
                    ShippingChoise = form.Get("ShippingChoise")
                };
                return(menuForm);
            }

            var route = controllerContext.RouteData;

            //from route value provider
            if (route.Values.Keys.Contains("reportPeriod"))
            {
                InputMenuViewModel menuRoute = new InputMenuViewModel {
                    ReportPeriod   = DateTime.ParseExact((string)route.Values["reportPeriod"], "MMyyyy", CultureInfo.InvariantCulture),
                    ShippingChoise = (string)route.Values["templateNumber"]
                };
                return(menuRoute);
            }

            return(new InputMenuViewModel());
        }
コード例 #2
0
        public ActionResult Index(SessionStorage storage, InputMenuViewModel menuView, EnumOperationType operationCategory = EnumOperationType.All, short page = 1, short pageSize = 9, bool asService = false)
        {
            if (this.Request.IsAjaxRequest() && this.ModelState.IsValid)
            {
                short recordCount;
                menuView.ReportPeriod = this._bussinesEngage.SyncActualDate(storage, menuView.ReportPeriod);

                //temp resolve (In some reason default binding not parse json to enum from queryString collection)
                var typeOfOperation = this.Request.QueryString["operationCategory"] == String.Empty ? (int)EnumOperationType.All : Int32.Parse(this.Request.QueryString["operationCategory"]);

                var model = new DispatchListViewModel()
                {
                    Dispatchs  = this._bussinesEngage.ShippingsViews((EnumOperationType)typeOfOperation, menuView.ReportPeriod, page, pageSize, out recordCount),
                    PagingInfo = new PagingInfo()
                    {
                        CurrentPage = page, ItemsPerPage = pageSize, TotalItems = recordCount, RoutingDictionary = this.Request.RequestContext.RouteData.Values
                    },
                };

                //tips: consider use web api mechanism instead of mvc implementation
                if (asService)
                {
                    return(this.Json(model, JsonRequestBehavior.AllowGet));
                }

                return(this.PartialView("ShippingSummary", model));
            }

            return(this.View());
        }
コード例 #3
0
        /// <summary>
        /// Filtering by Date and template shipping number
        /// </summary>
        /// <param name="storage"></param>
        /// <param name="menuView"></param>
        /// <param name="asService"></param>
        /// <returns></returns>
        public PartialViewResult GeneralMenu(SessionStorage storage, InputMenuViewModel menuView, bool asService = false)
        {
            menuView.ReportPeriod = storage.ReportPeriod;

            //Base controller info
            this.ViewBag.UserName    = this.CurrentADUser.Name;
            this.ViewBag.BrowserInfo = this.BrowserInfo;

            return(this.PartialView("ComplexNavbarMenu", menuView));
        }
コード例 #4
0
        /// <summary>
        /// Menu type operation
        /// </summary>
        /// <param name="storage"></param>
        /// <param name="menuView"></param>
        /// <param name="operationCategory"></param>
        /// <returns></returns>
        public PartialViewResult MenuTypeOperations(SessionStorage storage, InputMenuViewModel menuView, string operationCategory = null)
        {
            //reload page (save select report date)
            //menuView.ReportPeriod = _bussinesEngage.SyncActualDate(storage, menuView.ReportPeriod);

            //Передаем динамические типы операций
            //menuView.SelectedOperCategory = operationCategory;
            //menuView.TypesOfOperation = _bussinesEngage.GetTypeOfOpers(menuView.ReportPeriod);

            return(this.PartialView("FlexMenu"));
        }
コード例 #5
0
        public ActionResult Index(InputMenuViewModel menuView, bool asService = false)
        {
            if (this.Request.IsAjaxRequest() && this.ModelState.IsValid)
            {
                short recordCount;
                var   result = this._bussinesEngage.ShippingPreview(menuView.ShippingChoise, menuView.ReportPeriod, out recordCount);

                if (asService)
                {
                    return(this.Json(result, JsonRequestBehavior.DenyGet));
                }
            }

            return(new EmptyResult());
        }
コード例 #6
0
        public JsonResult SearchNumberShipping(InputMenuViewModel menuView)
        {
            var result = this._bussinesEngage.AutoCompleteShipping(menuView.ShippingChoise, menuView.ReportPeriod);

            return(this.Json(result, JsonRequestBehavior.DenyGet));
        }