예제 #1
0
 public void add()
 {
     using (var dbContext = new WashingtonRedskinsContext())
     {
         dbContext.Users.Add(this);
         dbContext.SaveChanges();
     }
 }
예제 #2
0
 public void add()
 {
     using (var dbContext = new WashingtonRedskinsContext())
     {
         dbContext.WorkHours.Add(this).State = EntityState.Added;
         dbContext.SaveChanges();
     }
 }
예제 #3
0
 public static void add(RegistrationsEdits regEdit)
 {
     using (var DbContext = new WashingtonRedskinsContext())
     {
         DbContext.RegistrationsEdits.Add(regEdit);
         DbContext.SaveChanges();
     }
 }
예제 #4
0
파일: Departments.cs 프로젝트: arhidia/WRS
 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();
     }
 }
예제 #5
0
        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();
            }
        }
예제 #6
0
        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();
            }
        }
예제 #7
0
        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);
        }
예제 #8
0
 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();
         }
     }
 }
예제 #9
0
        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);
        }
예제 #10
0
        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();
            }
        }