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(); }
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) { }
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; }