public void add() { using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Users.Add(this); dbContext.SaveChanges(); } }
public void add() { using (var dbContext = new WashingtonRedskinsContext()) { dbContext.WorkHours.Add(this).State = EntityState.Added; dbContext.SaveChanges(); } }
public static void add(RegistrationsEdits regEdit) { using (var DbContext = new WashingtonRedskinsContext()) { DbContext.RegistrationsEdits.Add(regEdit); DbContext.SaveChanges(); } }
public static void delete(uint id) { using (var dbContext = new WashingtonRedskinsContext()) { var orig = dbContext.Departments.Find(id); orig.DeletedAt = DateTime.Now; bool a = dbContext.ChangeTracker.HasChanges(); //double check if there was any change detected by EF or not? dbContext.SaveChanges(); } }
public static void delete(uint id) { var orig = get(id); using (var dbContext = new WashingtonRedskinsContext()) { orig.DeletedAt = DateTime.Now; dbContext.Entry(orig).State = EntityState.Modified; dbContext.SaveChanges(); } }
public static void edit(uint id, Users changes) { var orig = get(id); using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Entry(orig).CurrentValues.SetValues(changes); dbContext.Entry(orig).State = EntityState.Modified; dbContext.SaveChanges(); } }
public static void delete(uint id) { DateTime time; using (var dbContext = new WashingtonRedskinsContext()) { time = dbContext.Registrations.Find(id).Time; dbContext.Registrations.Find(id).DeletedAt = DateTime.Now; dbContext.SaveChanges(); } RegistrationsEdits.set(time); }
public static void set(DateTime time) { using (var dbContext = new WashingtonRedskinsContext()) { var regEdit = dbContext.RegistrationsEdits.Where(r => r.Time > time).FirstOrDefault(); if (regEdit != null) { regEdit.Time = time; dbContext.SaveChanges(); } } }
public static void edit(Registrations newRegistration, uint origId) { var orig = get(origId); using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Entry(orig).CurrentValues.SetValues(newRegistration); dbContext.Entry(orig).State = EntityState.Modified; dbContext.SaveChanges(); } var earliestTime = newRegistration.Time < orig.Time ? newRegistration.Time : orig.Time; RegistrationsEdits.set(earliestTime); }
public static void add(uint userId, uint statusId) { Registrations reg = new Registrations(); Users usr; using (var dbContext = new WashingtonRedskinsContext()) { usr = dbContext.Users.Find(userId); } reg.UserId = userId; reg.Time = DateTime.Now; reg.DepartmentId = usr.DepartmentId; reg.StatusId = statusId; using (var dbContext = new WashingtonRedskinsContext()) { dbContext.Add(reg); dbContext.SaveChanges(); } }