Exemple #1
0
        public async Task <IHttpActionResult> GetReport(int id)
        {
            ResultData result = new ResultData();

            try
            {
                var report = await Task.Run(() => db.Report.FirstOrDefault(c => c.id == id));

                if (report == null)
                {
                    return(ErrorResult(ResultCode.Faild, "报告不存在."));
                }
                var iResult = new { data = report, statusName = ApiEnum.TransferReportStatus(report.Status) };

                result = new ResultData {
                    code = (int)ResultCode.Successed, data = JsonConvert.SerializeObject(iResult)
                };
            }
            catch (Exception ex)
            {
                result = new ResultData {
                    code = (int)ResultCode.Faild, msg = ex.Message
                };
                LogClient.WriteLog(ex.Message, ex);
            }
            return(Json(result));
        }
Exemple #2
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));
        }