Exemplo n.º 1
0
 public ActionResult Create(Event anEvent)
 {
     if (ModelState.IsValid)
     {
         anEvent.CenterId = account.GetCurrentUserCenterId();
         repoService.eventRepo.Insert(anEvent);
         return RedirectToAction("Index");
     }
     return View(anEvent);
 }
Exemplo n.º 2
0
        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);
                }
            }
        }
Exemplo n.º 3
0
 public void Update(Event e)
 {
     db.Entry(e).State = EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 4
0
 public void Insert(Event e)
 {
     db.Events.Add(e);
     db.SaveChanges();
 }
Exemplo n.º 5
0
 public void Delete(Event e)
 {
     db.Events.Remove(e);
     db.SaveChanges();
 }
Exemplo n.º 6
0
        public ActionResult Edit(Event anEvent)
        {
            if (ModelState.IsValid)
            {
                anEvent.CenterId = account.GetCurrentUserCenterId();
                repoService.eventRepo.Update(anEvent);
                return RedirectToAction("Index");
            }
            int centerID = account.GetCurrentUserCenterId();

            return View(anEvent);
        }