public tb_notice_docment UpdateData(tb_notice_docment data)
        {
            var cData = GetDataById(data.Id).FirstOrDefault();

            cData.FileDesc = data.FileDesc;
            cData.FileId   = data.FileId;
            return(cData);
        }
 public tb_notice_docment AddData(tb_notice_docment data)
 {
     data.Id         = Guid.NewGuid().ToString("N");
     data.InsertDate = DateTime.Now;
     //data.Account = "";
     ef.tb_notice_docment.Add(data);
     return(data);
 }
        /// <summary>
        /// 保存公告附件信息
        /// </summary>
        /// <param name="Id">公告附件ID(区分新增还是修改)</param>
        /// <param name="FileDesc">文件描述</param>
        /// <param name="NoticeId">公告ID</param>
        /// <param name="FileId">文件ID</param>
        /// <returns></returns>
        public JsonResult SaveNoticeDocment(string Id, string FileDesc, string NoticeId, string FileId)
        {
            tb_notice_docment noticeFileModel = new tb_notice_docment();

            noticeFileModel.Id       = Id;
            noticeFileModel.FileDesc = FileDesc;
            noticeFileModel.NoticeId = NoticeId;
            noticeFileModel.FileId   = FileId;

            ResultModel resultModel = new ResultModel();

            try
            {
                if (String.IsNullOrEmpty(noticeFileModel.NoticeId))
                {
                    noticeFileModel.NoticeId = GetNewGuid();
                }
                if (String.IsNullOrEmpty(noticeFileModel.Id))
                {
                    noticeFileModel.Account = loginUser.Id;
                    noticeFileModel         = _NoticeDocmentBusiness.AddData(noticeFileModel);
                }
                else
                {
                    noticeFileModel = _NoticeDocmentBusiness.UpdateData(noticeFileModel);
                }
                ef.SaveChanges();
                resultModel.ResultCode = 1;
                resultModel.ResultData = noticeFileModel;
            }
            catch (DbEntityValidationException dex)
            {
                dex.ToString();
            }
            catch (Exception ex)
            {
                throw;
            }

            return(Json(resultModel));
        }