/// <summary> /// 创建一个附件 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个附件</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, FileUploader entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <summary> /// 创建一个附件 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个附件</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, SysEntities db, FileUploader entity) { int count = 1; foreach (string item in entity.SysPersonId.GetIdSort()) { SysPerson sys = new SysPerson { Id = item }; db.SysPerson.Attach(sys); entity.SysPerson.Add(sys); count++; } repository.Create(db, entity); if (count == repository.Save(db)) { return(true); } else { validationErrors.Add("创建出错了"); } return(false); }