예제 #1
0
 public ActionResult JobTypeCreateEdit(job_type job_type)
 {
     result              = jobTypeUtill.JobTypeCreateEdit(job_type);
     ViewBag.Title       = job_type == null ? "Job Create" : "Job Edit";
     ViewBag.action_name = STUtil.GetListAllActionByController("");
     return(Json(result));
 }
예제 #2
0
        public IActionResult AddJobType(string job_name)
        {
            ErrorRequestData err = null;

            if (string.IsNullOrWhiteSpace(job_name))
            {
                err = new ErrorRequestData()
                {
                    HttpStatusCode = 401, ErrorMessage = "参数错误"
                };
                return(new ContentResult()
                {
                    StatusCode = err.HttpStatusCode, Content = err.toJosnString(), ContentType = ConstantTypeString.JsonContentType
                });
            }
            try
            {
                job_type jt = new job_type()
                {
                    job_name = job_name, addtime = DateTime.Now, user_id = signedUser.user_uuid, uuid = UUID.getUUID()
                };
                dbContext.job_type.Add(jt);
                dbContext.SaveChanges();
                var list = dbContext.job_type.Where(x => x.user_id.Equals(signedUser.user_uuid)).ToList();
                return(Json(list));
            }
            catch (DbUpdateException dbex)
            {
                if (dbex.InnerException is PostgresException npge)
                {
                    err = new ErrorRequestData()
                    {
                        HttpStatusCode = 500, ErrorMessage = npge.Detail
                    };
                }
                else
                {
                    err = new ErrorRequestData()
                    {
                        HttpStatusCode = 500, ErrorMessage = dbex.Message
                    };
                }
                return(new ContentResult()
                {
                    StatusCode = err.HttpStatusCode, Content = err.toJosnString(), ContentType = ConstantTypeString.JsonContentType
                });
            }
            catch (Exception ex)
            {
                err = new ErrorRequestData()
                {
                    HttpStatusCode = 500, ErrorMessage = ex.Message
                };
                return(new ContentResult()
                {
                    StatusCode = err.HttpStatusCode, Content = err.toJosnString(), ContentType = ConstantTypeString.JsonContentType
                });
            }
        }
예제 #3
0
        public ActionResult JobType(string id)
        {
            STUtil.SetSessionValue(UserInfo.pageTitle.ToString(), "Job Type");
            job_type c = new job_type();

            if (id != null && id != "")
            {
                c = db.job_type.Find(Convert.ToInt32(id));
            }
            return(View(c));
        }