private void btnSubmitAddMemberToEvent_Click(object sender, EventArgs e) { EventAmountReduction ear = hc.AddMember(txtAmount.Text, txtReduction.Text); ear.thisMember = db.bareMembers.ToList().Find(y => y.Id == currentmember.Id); ear.ThisEvent = db.Events.ToList().Find(y => y.Id == currentevent.Id); db.eventAmountReductions.Add(ear); db.SaveChanges(); this.Close(); }
private void DeleteMemberFromEvent_Click(object sender, EventArgs e) { var memberid = hc.FindMemberId(firstname, surname); Event editevent = db.Events.Include("eventAmounts").ToList().Find(ee => ee.Id == currentevent.Id); EventAmountReduction ear = db.eventAmountReductions.Include("thisMember").ToList().Find(x => x.ThisEvent.Id == editevent.Id && x.thisMember.Id == memberid); db.eventAmountReductions.Remove(ear); db.SaveChanges(); EventParticipantsAdded.DataSource = db.Events.Include("eventAmounts").ToList().Find(epc => epc.Id == currentevent.Id).eventAmounts.Select(x => x.thisMember).ToList().Select(x => new { x.firstName, x.surName }).ToList(); EventMembers = db.eventAmountReductions.Include("thisMember").Where(x => x.ThisEvent.Id == editevent.Id).ToList(); EventMemberList.DataSource = hc.Search(txtEventSearchMembers.Text, EventMembers); }