Example #1
0
        public IHttpActionResult AuditReport()
        {
            ResultData result = new ResultData();

            try
            {
                int id     = Convert.ToInt32(HttpContext.Current.Request["id"]);
                int status = Convert.ToInt32(HttpContext.Current.Request["status"]);
                var report = db.Report.FirstOrDefault(en => en.id == id);
                if (report == null)
                {
                    return(ErrorResult(ResultCode.Faild, "报告不存在."));
                }
                report.Status = status;
                if (status == 1 || status == 2)
                {
                    report.VerifyFirstDate = DateTime.Now;
                }
                if (status == 3 || status == 4)
                {
                    report.VerifyLastDate = DateTime.Now;
                }

                db.Entry(report).State = System.Data.Entity.EntityState.Modified;
                int res = db.SaveChanges();
                if (res > 0)
                {
                    var iResult = new { data = report, statusName = ApiEnum.TransferReportStatus(report.Status) };
                    result = new ResultData
                    {
                        code = (int)ResultCode.Successed,
                        msg  = ApiEnum.TransferResultCode(ResultCode.Successed),
                        data = JsonConvert.SerializeObject(iResult)
                    };
                }
            }
            catch (Exception ex)
            {
                LogClient.WriteLog(ex.Message, ex);
                result = new ResultData()
                {
                    code = (int)ResultCode.Faild, msg = ApiEnum.TransferResultCode(ResultCode.Faild)
                };
            }
            return(Json(result));
        }
Example #2
0
        public async Task <IHttpActionResult> GetPageDirectory(int pageIndex)
        {
            ResultData result = new ResultData();

            try
            {
                var query = (from c in db.Directory.AsEnumerable()
                             where !string.IsNullOrEmpty(c.Title)
                             orderby c.PublishDate descending
                             select new
                {
                    id = c.id,
                    title = c.Title,
                    hyfl = c.hyfl,
                    publishDate = c.PublishDate,
                    sendLastDate = c.SendLastDate
                });

                var dItem = await Task.Run(() => query.Skip(pageSize * (pageIndex - 1)).Take(pageSize).ToList());

                result = new ResultData
                {
                    code      = (int)ResultCode.Successed,
                    pageIndex = pageIndex,
                    total     = query.Count(),
                    data      = JsonConvert.SerializeObject(dItem)
                };
            }
            catch (Exception ex)
            {
                result = new ResultData()
                {
                    code = (int)ResultCode.Faild, msg = ApiEnum.TransferResultCode(ResultCode.Faild)
                };
            }
            return(Json <ResultData>(result));
        }