예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 public int Create(Flow_Seal entity)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         db.Flow_Seal.Add(entity);
         return(db.SaveChanges());
     }
 }
예제 #5
0
 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());
     }
 }
예제 #6
0
 public bool IsExist(string id)
 {
     using (AppsDBEntities db = new AppsDBEntities())
     {
         Flow_Seal entity = GetById(id);
         if (entity != null)
         {
             return(true);
         }
         return(false);
     }
 }
예제 #7
0
 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());
     }
 }
예제 #8
0
 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);
     }
 }
예제 #9
0
        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);
            }
        }
예제 #10
0
        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));
            }
        }
예제 #11
0
        /// <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;
            }
        }