Esempio n. 1
0
 public void ShowEventById(int id)
 {
     using (var db = new EventsManagerEntities())
     {
         Event eve = db.Events.First(x => x.Id == id);
         PrintEvent(eve);
     }
 }
Esempio n. 2
0
 public void DeleteEventById(int id)
 {
     using (var db = new EventsManagerEntities())
     {
         var eve = db.Events.First(x => x.Id == id);
         db.Events.Remove(eve);
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 public void UpdateEndDateTime(int id, DateTime newEndDateTime)
 {
     using (var db = new EventsManagerEntities())
     {
         var eve = db.Events.First(x => x.Id == id);
         eve.EndDateTime     = newEndDateTime;
         db.Entry(eve).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 4
0
 public void UpdateLocation(int id, string newLocation)
 {
     using (var db = new EventsManagerEntities())
     {
         var eve = db.Events.First(x => x.Id == id);
         eve.Location        = newLocation;
         db.Entry(eve).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Esempio n. 5
0
 public void ShowAllEvents()
 {
     using (var db = new EventsManagerEntities())
     {
         foreach (var item in db.Events)
         {
             PrintEvent(item);
         }
     }
 }
Esempio n. 6
0
 public void GetAllIds(List <int> allIds)
 {
     allIds.Clear();
     using (var db = new EventsManagerEntities())
     {
         foreach (var item in db.Events)
         {
             int id = item.Id;
             allIds.Add(id);
         }
     }
 }
Esempio n. 7
0
 public void CreateEvent(string name, string location, DateTime startDateTime, DateTime endDateTime)
 {
     using (var db = new EventsManagerEntities())
     {
         EventManager.Event newEvent = new EventManager.Event()
         {
             Name          = name,
             Location      = location,
             StartDateTime = startDateTime,
             EndDateTime   = endDateTime
         };
         db.Events.Add(newEvent);
         db.SaveChanges();
     }
 }