示例#1
0
 private void Applybutton1_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         Event obj = (Event)dataGridView1.CurrentRow.DataBoundItem;;
         if (!Services.GetCollectionServices.GetAttendedEvents(Alumn).Contains(obj))
         {
             AlumnEvent alumnEvent = new AlumnEvent()
             {
                 Alumn = Alumn, Event = obj
             };
             Services.AddServices.AddAlumnEvent(alumnEvent);
             MessageBox.Show("Du har registrerat dig på eventet: " + obj.Title);
             LoadDataGridView();
         }
         else
         {
             MessageBox.Show("Du har redan registrerat dig på eventet: " + obj.Title);
         }
     }
     else
     {
         MessageBox.Show("Inget event valt");
     }
 }
示例#2
0
        internal void RemoveEvent(Services services, int id)
        {
            Alumn      a          = GetAlumn(services);
            Event      e          = services.GetServices.GetEvent(id);
            AlumnEvent alumnEvent = services.GetCollectionServices.GetAlumnEvents(a).Where(x => x.Event.Equals(e) && x.Alumn.Equals(a)).FirstOrDefault();

            services.DeleteServices.RemoveMyEvent(alumnEvent);
        }
示例#3
0
        internal void AttendEvent(Services services, int id)
        {
            Alumn alumn  = GetAlumn(services);
            Event @event = services.GetServices.GetEvent(id);

            if (!services.GetCollectionServices.GetAttendedEvents(alumn).Contains(@event))
            {
                AlumnEvent alumnEvent = new AlumnEvent()
                {
                    Alumn = alumn, Event = @event
                };
                services.AddServices.AddAlumnEvent(alumnEvent);
                MessageBox.Show("Du har registrerat dig på eventet: " + @event.Title);
            }
        }
示例#4
0
 public void AddAlumnEvent(AlumnEvent alumnEvent)
 {
     AppDbContext.AlumnEvent.Add(alumnEvent);
     AppDbContext.SaveChanges();
 }
示例#5
0
 public void RemoveMyEvent(AlumnEvent alumnEvent)
 {
     AppDbContext.AlumnEvent.Remove(alumnEvent);
     AppDbContext.SaveChanges();
 }