예제 #1
0
        /// <summary>
        /// 修改电子协议
        /// </summary>
        /// <param name="model"></param>
        /// <param name="fileList">附件</param>
        /// <returns></returns>
        public Result <int> UpdateProtocol(Base_Protocol model, List <Base_Files> fileList = null)
        {
            var oldModel = DataOperateBasic <Base_Protocol> .Get().GetModel(model.Id);

            model = FiterUpdate(oldModel, model);
            Result <int> result = new Result <int>();

            try
            {
                var rows = DataOperateBasic <Base_Protocol> .Get().Update(model);

                if (fileList != null)
                {
                    //删除之前的附件
                    DeleteFilesByTable(model.GetType().Name, new List <long>()
                    {
                        model.Id
                    });
                    //新增附件
                    AddFilesByTable(model, fileList);
                }
                result.Data = rows;
                result.Flag = EResultFlag.Success;

                WriteLog(AdminModule.ElectronicAgreement.GetText(), SystemRight.Add.GetText(), "修改电子协议:" + model.Id + ":" + model.Title);
            }
            catch (Exception ex)
            {
                result.Data      = -1;
                result.Flag      = EResultFlag.Failure;
                result.Exception = new ExceptionEx(ex, "UpdateDocTemplete");
            }
            return(result);
        }
예제 #2
0
        public ActionResult Add(Base_Protocol model)
        {
            Result <int>     result = new Result <int>();
            ResultView <int> view   = new ResultView <int>();

            model.Info = model.Info.FilterHtml();
            if (string.IsNullOrEmpty(model.Title))
            {
                view.Flag    = false;
                view.Message = "标题不能为空";
                return(Json(view));
            }
            if (string.IsNullOrEmpty(model.Info))
            {
                view.Flag    = false;
                view.Message = "内容不能为空";
                return(Json(view));
            }
            if (Request.Form["IsEnable"] == EnumState.Enable.ToString())
            {
                model.IsEnable = true;
            }
            else
            {
                model.IsEnable = false;
            }
            if (Request.Form["IsConfirm"] == EnumState.Confirmed.ToString())
            {
                model.IsConfirm = true;
            }
            else
            {
                model.IsConfirm = false;
            }

            string fileDataJson = Request.Form["fileDataJson"];

            List <Base_Files> fileList = JsonConvert.DeserializeObject <List <Base_Files> >(fileDataJson);

            foreach (var item in fileList)
            {
                item.TableId   = model.Id;
                item.TableName = model.GetType().Name;
            }

            using (AdminClientProxy proxy = new AdminClientProxy(ProxyEx(Request)))
            {
                result = proxy.AddProtocol(model, fileList);
                view   = result.ToResultView();
            }
            return(Json(view));
        }