Exemplo n.º 1
0
        public IHttpActionResult GetEventInfoFromName(string FirstAndLastName)
        {
            char[]   seperator = { '?', ' ', '_' };
            String[] Name      = FirstAndLastName.Split(seperator, 2, StringSplitOptions.RemoveEmptyEntries);
            string   FirstName = Name[0];
            string   LastName  = Name[1];

            using (RSVPEntities db = new RSVPEntities())
            {
                Guest guest = db.Guests.FirstOrDefault(x => x.FirstName == FirstName && x.LastName == LastName);

                //GuestDTO guestDTO = new GuestDTO
                //{
                //    GuestID = guest.GuestID,
                //    GuestGroupID = guest.GuestGroupID,
                //    FirstName = guest.FirstName,
                //    LastName = guest.LastName
                //};

                //return Ok(guestDTO);

                List <GuestEventJunction> guestEventJunction = db.GuestEventJunctions.Where(x => x.GuestID == guest.GuestID).ToList();

                GuestEventDTO guestEventDTO = new GuestEventDTO()
                {
                    GuestEventList = guestEventJunction.Select(x => x.EventID).ToList()
                };

                //return Ok(guestEventDTO);
                List <EventDTO> eventDTO = new List <EventDTO>();
                foreach (int eventx in guestEventDTO.GuestEventList)
                {
                    Event eventi = db.Events.FirstOrDefault(x => x.EventID == eventx);

                    eventDTO.Add(new EventDTO()
                    {
                        EventID        = eventi.EventID,
                        Title          = eventi.Title,
                        Subtitle       = eventi.Subtitle,
                        Description    = eventi.Description,
                        EventStartDate = eventi.EventStartDate.ToString("MMMM dd, yyyy"),
                        EventEndDate   = eventi.EventEndDate.ToString("MMMM dd, yyyy"),
                        Venue          = eventi.Venue,
                        Address        = eventi.Address,
                        EventStartTime = eventi.EventStartTime.ToString(),
                        EventEndTime   = eventi.EventEndTime.ToString(),
                        Details        = eventi.Details
                    });
                }


                return(Ok(eventDTO));
            }
        }
Exemplo n.º 2
0
        //return list of all event ids that a guest (Id) is invited to
        public IHttpActionResult GetEventsForGuest(int Id)
        {
            using (RSVPEntities db = new RSVPEntities())
            {
                List <GuestEventJunction> guestEventJunction = db.GuestEventJunctions.Where(x => x.GuestID == Id).ToList();

                GuestEventDTO guestEventDTO = new GuestEventDTO()
                {
                    GuestEventList = guestEventJunction.Select(x => x.EventID).ToList()
                };

                return(Ok(guestEventDTO));
            }
        }
Exemplo n.º 3
0
        //return list of all guest ids that a event (Id) is invited to
        public IHttpActionResult GetGuestsForEvent(int Id)
        {
            using (RSVPEntities db = new RSVPEntities())
            {
                db.Configuration.ProxyCreationEnabled = false;
                List <GuestEventJunction> guestEventJunction = db.GuestEventJunctions.Where(x => x.EventID == Id).ToList();

                GuestEventDTO guestEventDTO = new GuestEventDTO()
                {
                    GuestEventList = guestEventJunction.Select(x => x.GuestID).ToList()
                };


                List <Guest> guests = new List <Guest>();
                foreach (int guestId in guestEventDTO.GuestEventList)
                {
                    Guest guest = db.Guests.FirstOrDefault(x => x.GuestID == guestId);
                    guests.Add(guest);
                }

                return(Ok(guests.ToList()));
            }
        }