示例#1
0
        /// <summary>
        ///     Index 操作。
        /// </summary>
        /// <param name="orderField">排序字段。</param>
        /// <param name="orderDirection">排序方向。</param>
        /// <param name="pageSize">页面大小。</param>
        /// <param name="pageCurrent">当前页。</param>
        /// <returns></returns>
        public virtual ActionResult Index(string orderField, string orderDirection,
                                          int pageSize = 30, int pageCurrent = 1)
        {
            if (pageCurrent < 1)
            {
                pageCurrent = 1;
            }
            if (pageSize < 1)
            {
                pageSize = PageSizeList[0];
            }

            orderField     = string.IsNullOrWhiteSpace(orderField) ? PageConfig.DefaultSortname ?? "Id" : orderField;
            orderDirection = string.IsNullOrWhiteSpace(orderDirection)
                ? PageConfig.IsDescending ? "desc" : "asc"
                : orderDirection;

            var pagination = new Pagination
            {
                PageSize        = pageSize,
                PageCurrent     = pageCurrent,
                PageSizeList    = PageSizeList,
                DefualtPageSize = PageSizeList[0],
                OrderField      = orderField,
                OrderDirection  = orderDirection
            };

            var pageViewModel = EntityServicer.CreateIndexModel(pagination);

            return(View(pageViewModel));
        }
示例#2
0
        public virtual async Task <ActionResult> Edit([ModelBinder(typeof(EntityModelBinder))] TDto model)
        {
            var viewModel = await EntityServicer.CreateEditModelAsync(model);

            if (ModelState.IsValid)
            {
                await EntityServicer.UpdateEntity(model.MapTo());

                return(PartialView("_Form", viewModel));
            }
            else
            {
                Response.StatusCode             = 500;
                Response.TrySkipIisCustomErrors = true;
                return(PartialView("_Form", viewModel));
            }
        }
示例#3
0
        public virtual async Task <ActionResult> List(string orderField, string orderDirection,
                                                      int pageSize = 30, int pageCurrent = 1)
        {
            if (pageCurrent < 1)
            {
                pageCurrent = 1;
            }
            if (pageSize < 1)
            {
                pageSize = PageSizeList[0];
            }

            orderField     = string.IsNullOrWhiteSpace(orderField) ? PageConfig.DefaultSortname ?? "Id" : orderField;
            orderDirection = string.IsNullOrWhiteSpace(orderDirection)
                ? PageConfig.IsDescending ? "desc" : "asc"
                : orderDirection;

            var pageListViewModel = await EntityServicer.CreateListModelAsync(pageSize, pageCurrent, orderField,
                                                                              orderDirection);

            return(Json(pageListViewModel, new JsonSerializerSettings {
                DateFormatString = "yyyy-MM-dd HH:mm:ss"
            }));
        }
示例#4
0
        /// <summary>
        ///     Edit 操作。
        /// </summary>
        /// <param name="id">实体主键。</param>
        /// <returns></returns>
        public virtual async Task <ActionResult> Edit(string id)
        {
            var editModel = await EntityServicer.CreateEditModelAsync(id);

            return(View(editModel));
        }
示例#5
0
        /// <summary>
        ///     Detail 操作。
        /// </summary>
        /// <param name="id">实体主键。</param>
        /// <returns></returns>
        public virtual async Task <ActionResult> Detail(string id)
        {
            var detailModel = await EntityServicer.CreateDetailModelAsync(id);

            return(View(detailModel));
        }