Exemplo n.º 1
0
        public void UseConfirmDataToAdd(MSIT116APEXEntities db, IEnumerable <uRolePowerConfirmHistoryConfirmDataDetail> urpchcdds, T _entity)
        {
            db.Entry(_entity).State = EntityState.Added;
            DbEntityEntry <T> entry = db.Entry(_entity);

            foreach (var property in entry.CurrentValues.PropertyNames)
            {
                //var current = entry.CurrentValues.GetValue<object>(property);
                //if (current == null)
                //    entry.Property(property).IsModified = false;
                foreach (var urpchcdd in urpchcdds)
                {
                    if (urpchcdd.cColumnName == property)
                    {
                        entry.Property(property).CurrentValue = Convert.ChangeType(urpchcdd.cColumnValue, Type.GetType(urpchcdd.cColumnType));
                        urpchcdd.state = 1;
                    }
                }
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public void UseConfirmDataToUpdate(MSIT116APEXEntities db, IEnumerable <uRolePowerConfirmHistoryConfirmDataDetail> urpchcdds, T _entity)
        {
            db.Entry(_entity).State = EntityState.Modified;
            DbEntityEntry <T> entry = db.Entry(_entity);

            foreach (var property in entry.CurrentValues.PropertyNames)
            {
                //var current = entry.CurrentValues.GetValue<object>(property);
                //if (current == null)
                //    entry.Property(property).IsModified = false;
                foreach (var urpchcdd in urpchcdds)
                {
                    if (urpchcdd.cColumnName == property)
                    {
                        if (urpchcdd.cColumnType == "Byte[]")
                        {
                            string[] ptmps = urpchcdd.cColumnValue.Remove(urpchcdd.cColumnValue.Length - 1, 1).Split(',');
                            byte[]   pbtmp = new byte[ptmps.Length];
                            for (int i = 0; i < ptmps.Length; i++)
                            {
                                pbtmp[i] = Convert.ToByte(ptmps[i]);
                            }
                            entry.Property(property).CurrentValue = pbtmp;
                        }
                        else
                        {
                            entry.Property(property).CurrentValue = Convert.ChangeType(urpchcdd.cColumnValue, Type.GetType(urpchcdd.cColumnType));
                        }
                        urpchcdd.state = 1;
                    }
                }
            }
            try
            {
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        //MSIT116APEXEntities db = new MSIT116APEXEntities();

        public void ExecConfirmAction(MSIT116APEXEntities db, uRolePowerConfirmHistoryConfirmData urpchcd, T _entity)
        {
            IEnumerable <uRolePowerConfirmHistoryConfirmDataDetail> urpchcdds = db.uRolePowerConfirmHistoryConfirmDataDetail.Where(n => n.uRolePowerConfirmHistoryConfirmDataSn == urpchcd.urpchcdSn).ToList();

            if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Create.ToString())
            {
                UseConfirmDataToAdd(db, urpchcdds, _entity);
            }
            if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Remove.ToString())
            {
                db.Entry(_entity).State = EntityState.Deleted;
                urpchcd.state           = 1;
                foreach (var urpchcdd in urpchcdds)
                {
                    urpchcdd.state = 1;
                }
                db.SaveChanges();
            }
            if (urpchcd.execAction == SaveExecConfirmDataModelActionEnum.Update.ToString())
            {
                UseConfirmDataToUpdate(db, urpchcdds, _entity);
            }
        }
Exemplo n.º 4
0
 public AccountMethod()
 {
     dbUser = new Repository <AspNetUsers>();
     db     = new MSIT116APEXEntities();
 }
Exemplo n.º 5
0
 public Repository()
 {
     db    = new MSIT116APEXEntities();
     dbSet = db.Set <T>();
 }