public void Add(int id, int type, DateTime eventdate) { int centerid = account.GetCurrentUserCenterId(); var all_center_event = repoService.eventRepo.FindAllWithCenterId(centerid); var eve = all_center_event.Where(e => DateTime.Compare(e.Date, eventdate) == 0).SingleOrDefault(); if (eve == null) { eve = new Event(); eve.CenterId = account.GetCurrentUserCenterId(); eve.Date = eventdate; repoService.eventRepo.Insert(eve); } EventParticipant ep = new EventParticipant(); if (type == 1) { if (repoService.signInRepo.FindPrimaryGuardianByIdAndEventId(id, eve.Id). SingleOrDefault() == null) { var _primaryguardian = repoService.primaryGuardianRepo.FindById(id); ep.EventId = eve.Id; ep.PrimaryGuardianId = _primaryguardian.Id; ep.ParticipantType = "Primary"; repoService.signInRepo.Insert(ep); } } else if (type == 3) { if (repoService.signInRepo.FindChildByIdAndEventId(id,eve.Id) .SingleOrDefault() == null) { var _child = repoService.childRepo.FindById(id); ep.ChildId = _child.Id; ep.ParticipantType = "Child"; ep.EventId = eve.Id; repoService.signInRepo.Insert(ep); } } else { if (repoService.signInRepo.FindSecondaryGuardianByIdAndEventId(id, eve.Id). SingleOrDefault() == null) { var _secondaryguardian = repoService.secondaryGuardianRepo.FindById(id); ep.SecondaryGuardianId = _secondaryguardian.Id; ep.ParticipantType = "Secondary"; ep.EventId = eve.Id; repoService.signInRepo.Insert(ep); } } }
public void Update(EventParticipant e) { db.Entry(e).State = EntityState.Modified; db.SaveChanges(); }
public void Insert(EventParticipant e) { db.EventParticipants.Add(e); db.SaveChanges(); }
public void Delete(EventParticipant e) { db.EventParticipants.Remove(e); db.SaveChanges(); }