public bool Edit(ref ValidationErrors errors, Flow_SealModel model) { try { Flow_Seal entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Suggestion.Disable); return(false); } entity.CreateTime = model.CreateTime; entity.Id = model.Id; entity.Path = model.Path; entity.Using = model.Using; if (m_Rep.Edit(entity) == 1) { return(true); } else { errors.Add(Suggestion.EditFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public virtual bool Edit(ref ValidationErrors errors, Flow_SealModel model) { try { Flow_Seal entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.Id = model.Id; entity.Path = model.Path; entity.CreateTime = model.CreateTime; entity.SysUserId = model.SysUserId; if (m_Rep.Edit(entity)) { return(true); } else { errors.Add(Resource.NoDataChange); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public virtual bool Create(ref ValidationErrors errors, Flow_SealModel model) { try { Flow_Seal entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(false); } entity = new Flow_Seal(); entity.Id = model.Id; entity.Path = model.Path; entity.CreateTime = model.CreateTime; entity.SysUserId = model.SysUserId; if (m_Rep.Create(entity)) { return(true); } else { errors.Add(Resource.InsertFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
public int Create(Flow_Seal entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Flow_Seal.Add(entity); return(db.SaveChanges()); } }
public int Edit(Flow_Seal entity) { using (AppsDBEntities db = new AppsDBEntities()) { db.Flow_Seal.Attach(entity); db.Entry <Flow_Seal>(entity).State = System.Data.Entity.EntityState.Modified; //db.ObjectStateManager.ChangeObjectState(entity, EntityState.Modified); return(db.SaveChanges()); } }
public bool IsExist(string id) { using (AppsDBEntities db = new AppsDBEntities()) { Flow_Seal entity = GetById(id); if (entity != null) { return(true); } return(false); } }
public int Delete(string id) { using (AppsDBEntities db = new AppsDBEntities()) { Flow_Seal entity = db.Flow_Seal.SingleOrDefault(a => a.Id == id); if (entity != null) { db.Flow_Seal.Remove(entity); } return(db.SaveChanges()); } }
public Flow_SealModel GetById(string id) { if (IsExist(id)) { Flow_Seal entity = m_Rep.GetById(id); Flow_SealModel model = new Flow_SealModel(); model.CreateTime = entity.CreateTime; model.Id = entity.Id; model.Path = entity.Path; model.Using = entity.Using; return(model); } else { return(null); } }
public virtual Flow_SealModel GetById(object id) { if (IsExists(id)) { Flow_Seal entity = m_Rep.GetById(id); Flow_SealModel model = new Flow_SealModel(); model.Id = entity.Id; model.Path = entity.Path; model.CreateTime = entity.CreateTime; model.SysUserId = entity.SysUserId; return(model); } else { return(null); } }
public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(Flow_SealModel model) { ValidationErrors errors = new ValidationErrors(); try { Flow_Seal entity = await m_Rep.GetByIdAsync(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity = new Flow_Seal(); entity.Id = model.Id; entity.Path = model.Path; entity.CreateTime = model.CreateTime; entity.SysUserId = model.SysUserId; if (await m_Rep.CreateAsync(entity)) { return(new Tuple <ValidationErrors, bool>(errors, true)); } else { errors.Add(Resource.InsertFail); return(new Tuple <ValidationErrors, bool>(errors, false)); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(new Tuple <ValidationErrors, bool>(errors, false)); } }
/// <summary> /// 保存数据 /// </summary> public virtual void SaveImportData(IEnumerable <Flow_SealModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { Flow_Seal entity = new Flow_Seal(); entity.Id = ResultHelper.NewId; entity.Path = model.Path; entity.CreateTime = ResultHelper.NowTime; entity.SysUserId = model.SysUserId; db.Flow_Seal.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }