public List<EventModel> getHomeEvent(string UserID, string type) { if(UserID.Equals("undefined") || type.Equals("undefined")) { return getAllEvents(); } int _id = Convert.ToInt32(UserID); List<EventModel> _events = new List<EventModel>(); if (type.Equals("Host")) { FileUpload fileService = new FileUpload(); try { using (EventrixDBDataContext db = new EventrixDBDataContext()) { var query = (from ev in db.MAIN_EVENTs where ev.EH_ID.Equals(_id) select new EventModel { Name = ev.E_Name, EventID = ev.E_ID, Desc = ev.E_Desc, Type = ev.E_Type, HostID = Convert.ToInt32(ev.EH_ID), EventAddress = ev.AD_Id, EB_Quantity = Convert.ToInt32(ev.E_EB_Ticket), Reg_Quantity = Convert.ToInt32(ev.E_RG_Ticket), VIP_Quantity = Convert.ToInt32(ev.E_VIP_Ticket), VVIP_Quantity = Convert.ToInt32(ev.E_VVIP_Ticket), Product_Quantity = Convert.ToInt32(ev.E_NumProduct), City = ev.Address.AD_City, Province = ev.Address.AD_Province, Street = ev.Address.AD_StreetName, sDate = Convert.ToString(ev.E_StartDate), eDate = Convert.ToString(ev.E_EndDate), Start_Date = Convert.ToDateTime(ev.E_StartDate), Category = ev.Category, ImageLocation = fileService.getImageLocationByEventId(Convert.ToString(ev.E_ID)), }).OrderByDescending(t => t.Start_Date).ToList(); _events = query; }; } catch (Exception) { return null; } } else if(type.Equals("Guest")) //Guest Events { _events = GuestEventTicketList(Convert.ToString(_id)); if(_events == null) { return null; } } else //All Events { _events = getAllEvents(); } //Cut Count to 4 List<EventModel> data = new List<EventModel>(); int count = 1; foreach(EventModel ev in _events) { if(count >= 1 && count <= 4) { data.Add(ev); } else { break; } count++; } return data; }
//Get All Events that the guets is to attendcreateEvent public List<EventModel> GuestLiveEvent(string Guest_ID) { int _id = Convert.ToInt32(Guest_ID); List<EventModel> _events = null; FileUpload fileService = new FileUpload(); try { using (EventrixDBDataContext db = new EventrixDBDataContext()) { var innerJoinQuery = ( from guest in db.Guests where guest.G_ID.Equals(_id) join guest_ticket in db.Guest_Tickets on guest.G_ID equals guest_ticket.G_ID join tickets in db.Ticket_Templates on guest_ticket.ticket_temp_id equals tickets.TicketID join events in db.MAIN_EVENTs on tickets.eventid equals events.E_ID join img in db.EventImages on events.E_ID equals img.EventID select new EventModel { EventID = Convert.ToInt32(events.E_ID), HostID = Convert.ToInt32(events.EH_ID), EventAddress = Convert.ToInt32(events.AD_Id), Name = events.E_Name, Desc = events.E_Desc, Type = events.E_Type, // EB_Quantity = Convert.ToInt32(events.E_EB_Ticket), // Reg_Quantity = Convert.ToInt32(events.E_RG_Ticket), // VIP_Quantity = Convert.ToInt32(events.E_VIP_Ticket), // VVIP_Quantity = Convert.ToInt32(events.E_VVIP_Ticket), sDate = Convert.ToString(events.E_StartDate), Start_Date = Convert.ToDateTime(events.E_StartDate), eDate = Convert.ToString(events.E_StartDate), // Product_Quantity = Convert.ToInt32(events.E_NumProduct), ImageLocation = img.Location, Category = events.Category, }).OrderByDescending(t => t.Start_Date); _events = new List<EventModel>(); foreach (EventModel _event in innerJoinQuery) { string output = ""; if (_event.ImageLocation == null) { output = "Events/Eventrix_Default_Image.png"; } else { output = _event.ImageLocation.Substring(_event.ImageLocation.IndexOf('E')); //trim string path from Event } _event.ImageLocation = output; _events.Add(_event); } return _events; } } catch (Exception) { return null; } }
public List<EventModel> GuestEventTicketList(string Guest_ID) { int _id = Convert.ToInt32(Guest_ID); List<EventModel> _events = new List<EventModel>(); ImageFile images = new ImageFile(); List<EventTicket> _tickets = new List<EventTicket>(); TicketService ticketservice = new TicketService(); FileUpload fileService = new FileUpload(); try { using (EventrixDBDataContext db = new EventrixDBDataContext()) { var innerJoinQueryCount = (from guest in db.Guests where guest.G_ID.Equals(_id) join guest_ticket in db.Guest_Tickets on guest.G_ID equals guest_ticket.G_ID join tickets in db.Ticket_Templates on guest_ticket.ticket_temp_id equals tickets.TicketID join events in db.MAIN_EVENTs on tickets.eventid equals events.E_ID select events).Count(); if (innerJoinQueryCount != 0) { var innerJoinQuery = (from guest in db.Guests where guest.G_ID.Equals(_id) join guest_ticket in db.Guest_Tickets on guest.G_ID equals guest_ticket.G_ID join tickets in db.Ticket_Templates on guest_ticket.ticket_temp_id equals tickets.TicketID join events in db.MAIN_EVENTs on tickets.eventid equals events.E_ID select new EventModel { EventID = Convert.ToInt32(events.E_ID), HostID = Convert.ToInt32(events.EH_ID), EventAddress = Convert.ToInt32(events.AD_Id), Name = events.E_Name, // Desc = events.E_Desc, Type = events.E_Type, EB_Quantity = Convert.ToInt32(events.E_EB_Ticket), Reg_Quantity = Convert.ToInt32(events.E_RG_Ticket), VIP_Quantity = Convert.ToInt32(events.E_VIP_Ticket), VVIP_Quantity = Convert.ToInt32(events.E_VVIP_Ticket), sDate = Convert.ToString(events.E_StartDate), Start_Date = Convert.ToDateTime(events.E_StartDate), eDate = Convert.ToString(events.E_StartDate), Product_Quantity = Convert.ToInt32(events.E_NumProduct), Category = events.Category, City = events.Address.AD_City, Province = events.Address.AD_Province, Street = events.Address.AD_StreetName, // mycount = Convert.ToInt32(guest_ticket.Guest_QRCodes.Where(pe => pe.ticket_Id.Equals(guest_ticket.ticket_Id)).Select(p => p.Credit).First()), //EventImage // EventImage = fileService.getImageById(Convert.ToString(events.E_ID)), ImageLocation = fileService.getImageLocationByEventId(Convert.ToString(events.E_ID)), eventTicket = ticketservice.GetGuestTicketForEvent(Guest_ID, Convert.ToString(events.E_ID)), }).OrderByDescending(t => t.Start_Date).ToList(); _events = new List<EventModel>(); foreach (EventModel _Event in innerJoinQuery) { _events.Add(_Event); } } return _events; } } catch (Exception) { return null; } }
public List<EventModel> getAllEventsByHostID(string HostID, string Guest_ID) { if(Convert.ToInt32(HostID) != 0 && Convert.ToInt32(Guest_ID) == 0) { FileUpload fileService = new FileUpload(); int _id = Convert.ToInt32(HostID); try { using (EventrixDBDataContext db = new EventrixDBDataContext()) { return db.MAIN_EVENTs.Where(ev => ev.EH_ID == _id).Select(ev => new EventModel { Name = ev.E_Name, EventID = ev.E_ID, Desc = ev.E_Desc, Type = ev.E_Type, HostID = Convert.ToInt32(ev.EH_ID), EventAddress = ev.AD_Id, EB_Quantity = Convert.ToInt32(ev.E_EB_Ticket), Reg_Quantity = Convert.ToInt32(ev.E_RG_Ticket), VIP_Quantity = Convert.ToInt32(ev.E_VIP_Ticket), VVIP_Quantity = Convert.ToInt32(ev.E_VVIP_Ticket), Product_Quantity = Convert.ToInt32(ev.E_NumProduct), sDate = Convert.ToString(ev.E_StartDate), eDate = Convert.ToString(ev.E_EndDate), City = ev.Address.AD_City, Province = ev.Address.AD_Province, Street = ev.Address.AD_StreetName, Start_Date = Convert.ToDateTime(ev.E_StartDate), Category = ev.Category, ImageLocation = fileService.getImageLocationByEventId(Convert.ToString(ev.E_ID)), }).OrderByDescending(t => t.Start_Date).ToList(); } } catch (Exception) { return null; } }else //Guest Events { int _id = Convert.ToInt32(Guest_ID); List<EventModel> _events = null; try { using (EventrixDBDataContext db = new EventrixDBDataContext()) { var innerJoinQuery = from guest in db.Guests where guest.G_ID.Equals(_id) join guest_ticket in db.Guest_Tickets on guest.G_ID equals guest_ticket.G_ID join tickets in db.Ticket_Templates on guest_ticket.ticket_temp_id equals tickets.TicketID join events in db.MAIN_EVENTs on tickets.eventid equals events.E_ID select new EventModel { EventID = Convert.ToInt32(events.E_ID), HostID = Convert.ToInt32(events.EH_ID), EventAddress = Convert.ToInt32(events.AD_Id), Name = events.E_Name, Desc = events.E_Desc, Type = events.E_Type, EB_Quantity = Convert.ToInt32(events.E_EB_Ticket), Reg_Quantity = Convert.ToInt32(events.E_RG_Ticket), VIP_Quantity = Convert.ToInt32(events.E_VIP_Ticket), VVIP_Quantity = Convert.ToInt32(events.E_VVIP_Ticket), sDate = Convert.ToString(events.E_StartDate), eDate = Convert.ToString(events.E_StartDate), City = events.Address.AD_City, Province = events.Address.AD_Province, Street = events.Address.AD_StreetName, Category = events.Category, Product_Quantity = Convert.ToInt32(events.E_NumProduct), }; _events = new List<EventModel>(); foreach(EventModel ev in innerJoinQuery) { _events.Add(ev); } return _events; } } catch (Exception) { return null; } } }