Exemple #1
0
        public void AddUpdateConfigEntries(ConfigMultiEntries request)
        {
            using (var context = new TICPuppyLoveDbContext())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    context.dbTransaction = dbContextTransaction;

                    ConfigDTO cdto = new ConfigDTO { configs = request.ConfigEntries };

                    //set inserts first
                    cdto.CreateRefConfigNewUserIntances();

                    if (cdto.refConfigEntries.Count() > 0)
                    {
                        context.Add(cdto);
                    }

                    //now do updates
                    cdto.CreateRefConfigUpdateInstances();

                    if (cdto.refConfigEntries.Count() > 0)
                    {
                        context.Update(cdto);
                    }

                    // everything good, commit transaction
                    dbContextTransaction.Commit();
                }
            }
        }
        public void Add(ConfigDTO cdto)
        {
            foreach (Ref_Config rc in cdto.refConfigEntries)
            {
                base.Ref_Config.Add(rc);
            }

            SaveChanges();
        }
        public void Update(ConfigDTO cdto)
        {
            foreach (Ref_Config rc in cdto.refConfigEntries)
            {
                base.Ref_Config.Attach(rc);
                base.Entry(rc).State = EntityState.Modified;

                //below is how you tell EF only to update specific columns - leaving in for reference.
                //base.Entry(rc).Property(a => a.Name).IsModified = true;
                //base.Entry(rc).Property(a => a.Value).IsModified = true;
            }

            SaveChanges();
        }
Exemple #4
0
        public Int32 DeleteConfigurations(ConfigMultiEntries request)
        {
            Int32 response = -1;
            using (var context = new TICPuppyLoveDbContext())
            {
                using (var dbContextTransaction = context.Database.BeginTransaction())
                {
                    context.dbTransaction = dbContextTransaction;

                    ConfigDTO cdto = new ConfigDTO { configs = request.ConfigEntries };

                    cdto.refConfigEntries = context.GetRefConfigData();
                    cdto.refConfigEntries = cdto.GetSpecificRefConfigs();

                    context.Ref_Config.RemoveRange(cdto.refConfigEntries);
                    response =  context.SaveChanges();

                    // everything good, commit transaction
                    dbContextTransaction.Commit();
                }
            }

            return response;
        }
 public void Delete(ConfigDTO cdto)
 {
 }
Exemple #6
0
        public List<ConfigEntry> GetAllConfigurations()
        {
            List<ConfigEntry> response = new List<ConfigEntry>();
            var result = new ConfigDTO();
            using (var dbEntities = new TICPuppyLoveDbContext())
            {
                result.refConfigEntries = dbEntities.GetRefConfigData();
                response = result.CreateConfigCollection();
            }

            return response;
        }