コード例 #1
0
        public ActionResult Update(WorkOrderDto dto)
        {
            var workorder = _workOrderContract.Edit(dto.Id);

            if (AuthorityHelper.OperatorId == null || AuthorityHelper.OperatorId <= 0)
            {
                return(Json(new OperationResult(OperationResultType.Error, "请重新登陆"), JsonRequestBehavior.AllowGet));
            }
            if (workorder == null)
            {
                return(Json(new OperationResult(OperationResultType.Error, "该工单不存在"), JsonRequestBehavior.AllowGet));
            }
            if (dto.WorkOrderTitle != workorder.WorkOrderTitle && dto.WorkOrderTitle.Trim() == "")
            {
                return(Json(new OperationResult(OperationResultType.Error, "请填写工单标题"), JsonRequestBehavior.AllowGet));
            }
            if (dto.WorkOrderCategoryId != workorder.WorkOrderCategoryId && dto.WorkOrderCategoryId <= 0)
            {
                return(Json(new OperationResult(OperationResultType.Error, "请选择类型"), JsonRequestBehavior.AllowGet));
            }
            if (dto.Content != dto.Content && workorder.Content.Trim() == "")
            {
                return(Json(new OperationResult(OperationResultType.Error, "请填写工单内容"), JsonRequestBehavior.AllowGet));
            }
            if (dto.ImgAddress != null && dto.ImgAddress.Trim().Length > 0 && !FileHelper.FileIsExist(dto.ImgAddress))
            {
                return(Json(new OperationResult(OperationResultType.Error, "图片不存在"), JsonRequestBehavior.AllowGet));
            }
            workorder.WorkOrderTitle      = dto.WorkOrderTitle;
            workorder.WorkOrderCategoryId = dto.WorkOrderCategoryId;
            workorder.Content             = dto.Content;
            if (dto.ImgAddress.Trim() != workorder.ImgAddress.Trim() && FileHelper.FileIsExist(dto.ImgAddress))
            {
                workorder.ImgAddress = dto.ImgAddress;
            }
            var result = _workOrderContract.Update(workorder);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }