Ejemplo n.º 1
0
        public ActionResult Index(Guid?EventID)
        {
            AnimalRescueEntities svc = new AnimalRescueEntities();

            if (EventID.HasValue)
            {
                // if an event is selected then show the registrations for that event.
                var attendees = svc.Event_Attendee.Where(a => a.ID.Equals(EventID)).ToList <Event_Attendee>();
                //foreach (var attendee in attendees)
                //{
                //    svc.Event_Registration.Where(reg => reg.)
                //}

                //if (Request.IsAjaxRequest())
                //{
                //    //return PartialView("AttendeesList", attendees.AsEnumerable<AdoptionApplicationViewModel>());
                //}
                //List<Event_AttendeeViewModel> attendeesVM = new List<Event_AttendeeViewModel>();
                //attendeesVM = Mapper.Map<List<Event_Attendee>, List<Event_AttendeeViewModel>>(attendees.ToList<Event_Attendee>());
                return(View(attendees));
            }
            else
            {
                // if no event selected then send a list of events to the client to be selected
                var events = svc.Events;
                //events.Expand(e => e.Event_Registration);//get registartions
                //events.Expand(e => e.Entity_Base); //get owner of event

                if (Request.IsAjaxRequest())
                {
                    //return PartialView("AdoptionApplicationList", events.AsEnumerable<AdoptionApplicationViewModel>());
                }
                return(View(events));
            }

            //var eventRegs = svc.Event_Registration;
            //eventRegs.Expand(reg => reg.Event_Attendee); // get attendees
            //eventRegs.Expand(reg => reg.Event); // get event info for the registrations
        }
Ejemplo n.º 2
0
        public ActionResult Create(Event_RegistrationViewModel eventRegVM)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var eventRegDB = new Event_Registration();
                    eventRegDB = Mapper.Map <Event_RegistrationViewModel, Event_Registration>(eventRegVM);

                    AnimalRescueEntities svc = new AnimalRescueEntities();
                    svc.AddToEvent_Registration(eventRegDB);

                    // Send the insert to the data service.
                    svc.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }