示例#1
0
 public void ShowEventById(int id)
 {
     using (var db = new EventsManagerEntities())
     {
         Event eve = db.Events.First(x => x.Id == id);
         PrintEvent(eve);
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#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();
     }
 }
示例#5
0
 public void ShowAllEvents()
 {
     using (var db = new EventsManagerEntities())
     {
         foreach (var item in db.Events)
         {
             PrintEvent(item);
         }
     }
 }
示例#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);
         }
     }
 }
示例#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();
     }
 }