Esempio n. 1
0
 public void CreateGroup(string username, EPGroup newGroup)
 {
     using (var db = new EPContext())
     {
         var tempUser = db.Users.FirstOrDefault(u => u.Username == username);
         newGroup.Name = newGroup.Name + "$" + username + "_" + Guid.NewGuid().ToString() + "_G";
         db.Entry(tempUser).Collection(p => p.Calendars).Load();
         var newEntry = new EPEntry(tempUser, newGroup, tempUser.Calendars.Count);
         tempUser.Calendars.Add(newEntry);
         newGroup.Entryes.Add(newEntry);
         db.SaveChanges();
     }
 }
Esempio n. 2
0
 public void AddGroup(string username, string groupName)
 {
     using (var db = new EPContext())
     {
         if (!IsUserInGroup(username, groupName))
         {
             var tempUser = db.Users.FirstOrDefault(u => u.Username == username);
             var tempGroup = db.EPCalendars.FirstOrDefault(g => g.IsGroup && g.Name == groupName);
             db.Entry(tempGroup).Collection(p => p.Entryes).Load();
             db.Entry(tempUser).Collection(p => p.Calendars).Load();
             var newEntry = new EPEntry(tempUser, tempGroup, tempUser.Calendars.Count);
             newEntry.Priority = tempUser.Calendars.Count;
             tempGroup.Entryes.Add(newEntry);
             tempUser.Calendars.Add(newEntry);
             db.SaveChanges();
         }
     }
 }
Esempio n. 3
0
 public void AddCalendar(string username, EPCalendar newCalendar)
 {
     EPCalendar tempCalendar = new EPCalendar();
     using (var db = new EPContext())
     {
         var tempUser = db.Users.FirstOrDefault(u => u.Username == username);
         tempCalendar.Name = newCalendar.Name + "$" + username + "_" + Guid.NewGuid().ToString() + "_C";
         db.Entry(tempUser).Collection(p => p.Calendars).Load();
         var newEntry = new EPEntry(tempUser, tempCalendar, tempUser.Calendars.Count);
         tempUser.Calendars.Add(newEntry);
         tempCalendar.Entryes.Add(newEntry);
         db.SaveChanges();
         db.Entry(tempCalendar).Collection(p => p.Events).Load();
         foreach (var eve in newCalendar.Events)
             tempCalendar.Events.Add(new EPEvent { Calendar = tempCalendar, EventID = eve.EventID, End = eve.End, Start = eve.Start, Summary = eve.Summary });
         db.SaveChanges();
     }
 }
Esempio n. 4
0
 public void CreateUser(string username)
 {
     using (var db = new EPContext()) {
         var newUser = new EPUser();
         newUser.Username = username;
         db.Users.Add(newUser);
         var newCalendar = new EPCalendar();
         newCalendar.Name = "Main$" + username + Guid.NewGuid().ToString();
         var newEntry = new EPEntry(newUser, newCalendar, 0);
         newUser.Calendars.Add(newEntry);
         newCalendar.Entryes.Add(newEntry);
         db.SaveChanges();
     }
 }