Exemplo n.º 1
0
 public static TicketType getTicketTypeByTypeName(string whatName)
 {
     return(Mappings.MappingDtos.EntityTicketTypeToModelTicketType(TicketTypeUtils.GetTicketTypeByTypeName(whatName)));
 }
Exemplo n.º 2
0
        //GET : Tickets
        public ActionResult ListTickets(int?page, string searchString, bool active = false, bool inactive = false, string category = "")
        {
            List <DataAccessLayer.Entities.Ticket> ticketContextList = TicketUtils.GetAllTickets();
            List <Ticket>     ticketList = Mappings.MappingDtos.EntityTicketLIstToModelTicketAsList(ticketContextList);
            List <TicketType> type       = Mappings.MappingDtos.EntityTicketLIstToModelTicketTypeAsList(TicketTypeUtils.GetAllTicketTypes());

            ViewBag.tklist = type;
            if (active && inactive && String.IsNullOrEmpty(category))
            {
                if (!String.IsNullOrEmpty(searchString))
                {
                    ticketList = ticketList.Where(s => s.TicketName.ToLower().Contains(searchString.ToLower())).ToList();
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(searchString))
                {
                    ticketList = ticketList.Where(s => s.TicketName.ToLower().Contains(searchString.ToLower())).ToList();
                }
                if (!String.IsNullOrEmpty(category))
                {
                    ticketList = ticketList.Where(s => s.TicketName == category).ToList();
                }
                if (active)
                {
                    List <Ticket> tic = new List <Ticket>();
                    foreach (var ticket in ticketList)
                    {
                        var ticketType = TicketTypeUtils.GetTicketTypeByTypeName(ticket.TicketName);
                        var date       = ticket.StartDate;
                        if (ticketType.DayNum != 0 && ticketType.OccasionNum != 0)
                        {
                            if (ticketType.DayNum - ticket.LoginsNum > 0)
                            {
                                tic.Add(ticket);
                            }
                        }

                        if (ticketType.DayNum != 0 && date.AddDays(ticketType.DayNum) > DateTime.Now)
                        {
                            if (ticketType.DayNum - ticket.LoginsNum > 0)
                            {
                                tic.Add(ticket);
                            }
                        }
                        if (ticketType.OccasionNum != 0)
                        {
                            if (ticketType.OccasionNum - ticket.LoginsNum > 0)
                            {
                                tic.Add(ticket);
                            }
                        }
                    }

                    ticketList = tic;
                }
                if (inactive)
                {
                    List <Ticket> tic = new List <Ticket>();
                    foreach (var ticket in ticketList)
                    {
                        var ticketType = TicketTypeUtils.GetTicketTypeByTypeName(ticket.TicketName);
                        var date       = ticket.StartDate;
                        if (ticketType.DayNum != 0 && ticketType.OccasionNum != 0)
                        {
                            if (ticketType.DayNum - ticket.LoginsNum < 0)
                            {
                                tic.Add(ticket);
                            }
                        }

                        if (ticketType.DayNum != 0 && date.AddDays(ticketType.DayNum) < DateTime.Now)
                        {
                            if (ticketType.DayNum - ticket.LoginsNum < 0)
                            {
                                tic.Add(ticket);
                            }
                        }
                        if (ticketType.OccasionNum != 0)
                        {
                            if (ticketType.OccasionNum - ticket.LoginsNum < 0)
                            {
                                tic.Add(ticket);
                            }
                        }
                    }

                    ticketList = tic;
                }
            }
            return(View(ticketList.ToPagedList(page ?? 1, pageSize: 20)));
        }