Ejemplo n.º 1
0
        public void Insert(IEnumerable <EventClasses.Event> eventsList)
        {
            var parsedList = ParseToDbEventList(eventsList);

            using (ItEventsParserDbContext context = new ItEventsParserDbContext())
            {
                if (!(context.Events.Any()))
                {
                    foreach (var item in parsedList)
                    {
                        item.HasSentEmail = "Yes";
                        context.Events.Add(item);
                        context.SaveChanges();
                    }
                }
                else
                {
                    foreach (var item in parsedList)
                    {
                        if (!(context.Events.Any(obj => obj.Name == item.Name && obj.Link == item.Link)))
                        {
                            context.Events.Add(item);
                            context.SaveChanges();
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void UpdateEvent(int dbEventId, DB.Events newEvent)
 {
     using (ItEventsParserDbContext context = new ItEventsParserDbContext())
     {
         if (context.Events.Any())
         {
             var dep = context.Events.First(item => item.id == dbEventId);
             if (newEvent.Name != null)
             {
                 dep.Name = newEvent.Name;
             }
             if (newEvent.City != null)
             {
                 dep.City = newEvent.City;
             }
             if (newEvent.Date != null)
             {
                 dep.Date = newEvent.Date;
             }
             if (newEvent.Description != null)
             {
                 dep.Description = newEvent.Description;
             }
             if (newEvent.Link != null)
             {
                 dep.Link = newEvent.Link;
             }
             if (newEvent.HasSentEmail != null)
             {
                 dep.HasSentEmail = newEvent.HasSentEmail;
             }
             context.SaveChanges();
         }
     }
 }
Ejemplo n.º 3
0
 public void DeleteSingle(string name)
 {
     using (ItEventsParserDbContext context = new ItEventsParserDbContext())
     {
         if (context.Events.Any())
         {
             DB.Events db = new DB.Events()
             {
                 Name = name
             };
             context.Events.Attach(db);
             context.Events.Remove(db);
             context.SaveChanges();
         }
     }
 }
Ejemplo n.º 4
0
 public void DeleteSingle(int id)
 {
     using (ItEventsParserDbContext context = new ItEventsParserDbContext())
     {
         if (context.Events.Any())
         {
             DB.Events db = new DB.Events()
             {
                 id = id
             };
             context.Events.Attach(db);
             context.Events.Remove(db);
             context.SaveChanges();
         }
     }
 }