Пример #1
0
        /// <summary>
        /// 查询所有CPS数据
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult QueryCpsList()
        {
            var response = new AjaxResponse();
            try
            {
                var cpsList = new CpsService().QueryAll();

                if (cpsList == null)
                {
                    response.State = 2;
                    response.Message = "没有获取到CPS数据";
                    return this.Json(response, JsonRequestBehavior.AllowGet);
                }

                var items = new List<SelectListItem>();
                foreach (var cps in cpsList)
                {
                    items.Add(new SelectListItem { Text = cps.Name, Value = cps.ID.ToString() });
                }

                response.State = 1;
                response.Data = items;
                return this.Json(response, JsonRequestBehavior.AllowGet);
            }
            catch (Exception exception)
            {
                response.State = -1;
                response.Message = exception.Message;
                return this.Json(response, JsonRequestBehavior.AllowGet);
                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// 查询Cps合作平台信息列表.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult QueryCps([DataSourceRequest] DataSourceRequest request)
        {
            this.cpsService = new CpsService();

            if (request.Page <= 0)
            {
                request.Page = 1;
            }

            int totalCount;
            List<Cps> list;
            try
            {
                var paging = new Paging("[Cps]", null, "ID", null, request.Page, request.PageSize);

                int pageCount;
                list = this.cpsService.Query(paging, out pageCount, out totalCount);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            if (list == null)
            {
                return this.View();
            }

            var modelList = new List<CpsModel>();
            foreach (var cps in list)
            {
                modelList.Add(DataTransfer.Transfer<CpsModel>(cps, typeof(Cps)));
            }

            var result = new DataSourceResult { Data = modelList, Total = totalCount };
            return this.Json(result);
        }
Пример #3
0
        public ActionResult ModifyCps([DataSourceRequest] DataSourceRequest request, CpsModel cpsModel)
        {
            try
            {
                if (cpsModel != null)
                {
                    this.cpsService = new CpsService();

                    var userLevel = DataTransfer.Transfer<Cps>(cpsModel, typeof(CpsModel));

                    this.cpsService.Modify(userLevel);
                }

                return this.Json(new[] { cpsModel }.ToDataSourceResult(request, this.ModelState));
            }
            catch
            {
                return this.View();
            }
        }
Пример #4
0
        /// <summary>
        /// 查询所有CPS信息
        /// </summary>
        /// <param name="request">
        /// 请求对象
        /// </param>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult QueryAllCps([DataSourceRequest] DataSourceRequest request)
        {
            List<Cps> list;
            try
            {
                this.cpsService = new CpsService();

                list = this.cpsService.QueryAll();
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            if (list == null)
            {
                return this.Json(null, JsonRequestBehavior.AllowGet);
            }

            var modelList = new List<CpsModel>();
            foreach (var cps in list)
            {
                modelList.Add(DataTransfer.Transfer<CpsModel>(cps, typeof(Cps)));
            }

            return this.Json(modelList, JsonRequestBehavior.AllowGet);
        }
Пример #5
0
        public ActionResult AddCps([DataSourceRequest] DataSourceRequest request, CpsModel cpsModel)
        {
            try
            {
                if (cpsModel != null)
                {
                    this.cpsService = new CpsService();

                    var cps = DataTransfer.Transfer<Cps>(cpsModel, typeof(CpsModel));

                    cpsModel.ID = this.cpsService.AddCps(cps);

                    if (cpsModel.ID > 0)
                    {
                        return this.Json(new[] { cpsModel }.ToDataSourceResult(request, this.ModelState));
                    }
                }
            }
            catch (Exception exception)
            {
                throw new Exception("添加Cps时发生错误", exception);
            }

            return this.View();
        }