示例#1
0
        public JsonResult CreateSvgRows(SectorInfo sectorInfo)
        {
            int sectorId = 0;
            int maxRow = 0;
            int maxCol = 0;
            int svgX = 0;
            int svgY = 25;
            int spaceX = 10;
            int spaceY = 45;

            if (sectorInfo.SectorId == 0)
            {
                using (var ctx = new TicketDbContext())
                {
                    sectorId = ctx.Sectors.First().Id;
                    maxRow = ctx.Seats.Where(r => r.Sector.Id == sectorId).Max(s => s.Row);
                    maxCol = ctx.Seats.Where(r => r.Sector.Id == sectorId).Max(c => c.Number);
                }
            }
            else
            {
                sectorId = sectorInfo.SectorId;
                maxRow = sectorInfo.RowNumber;
                maxCol = sectorInfo.SeatNumber;

            }

            SVG_model[] k = new SVG_model[maxRow];
            int rowNumberX = maxCol*70 + 140;

            for (int i = 0; i < maxRow; i++)
            {
                SVG_model test = new SVG_model();
                test.svgId = "R " + (i + 1) + "";
                test.svgRow = i + 1;
                test.svgX = 25;
                test.svgY = (svgY + spaceY)*i + 30;
                k[i] = test;
            }

            return Json(k, JsonRequestBehavior.AllowGet);
        }
示例#2
0
        public JsonResult CreateSvgItems(SectorInfo sectorInfo)
        {
            int sectorId = 0;
            int maxRow = 0;
            int maxCol = 0;
            int eventId;
            int svgX = 60;
            int svgY = 60;
            int spaceX = 10;
            int spaceY = 10;

            if (sectorInfo.SectorId == 0)
            {
                using (var ctx = new TicketDbContext())
                {
                    sectorId = ctx.Sectors.First().Id;
                    eventId = ctx.Events.First().Id;
                    maxRow = ctx.Seats.Where(r => r.Sector.Id == sectorId).Max(s => s.Row);
                    maxCol = ctx.Seats.Where(r => r.Sector.Id == sectorId).Max(c => c.Number);
                }
            }
            else
            {
                sectorId = sectorInfo.SectorId;
                eventId = sectorInfo.EventId;
                maxRow = sectorInfo.RowNumber;
                maxCol = sectorInfo.SeatNumber;
            }

            SVG_model[,] k = new SVG_model[maxRow, maxCol];

            List<Seat> seats = new List<Seat>();
            List<Ticket> tickets = new List<Ticket>();
            List<int> seatsIdList = new List<int>();

            using (var ctx = new TicketDbContext())
            {
                seats = ctx.Seats.Where(s => s.Sector.Id == sectorId).Cast<Seat>().ToList();
                tickets = ctx.Tickets.Where(t => t.Event.Id == eventId).Cast<Ticket>().ToList();
                seatsIdList = tickets.Select(t => t.Seat.Id).ToList();
            }

            int i = 0;
            int j = 0;
            foreach (var seat in seats)
            {
                var test = new SVG_model();
                test.svgReserved = seatsIdList.Find(s => s == seat.Id) != 0;
                test.svgId = "r" + seat.Id;
                test.svgRow = i + 1;
                test.svgCol = j + 1;
                test.svgX = (svgX + spaceX)*j + 60;
                test.svgY = (svgY + spaceY)*i;
                k[i, j] = test;
                j++;
                if (j == maxCol)
                {
                    j = 0;
                    i++;
                }

            }
            return Json(k, JsonRequestBehavior.AllowGet);
        }
示例#3
0
        public ActionResult TicketInfo()
        {
            TicketInfo ticketInfo;
            using (var ctx = new TicketDbContext())
            {
                ticketInfo = new TicketInfo()
                {
                    Events = ctx.Events.Select(e => new DropDownListItem() { Id = e.Id, Value = e.Name }).ToList(),
                    EventDate = ctx.Events.First().Date.ToString(CultureInfo.InvariantCulture),
                    Stadium = ctx.Stadiums.First().Name,
                    Sectors = ctx.Sectors.Select(e => new DropDownListItem() { Id = e.Id, Value = e.Name }).ToList(),
                    Price = ctx.Events.First().Price
                };
            }

            return View(ticketInfo);
        }
示例#4
0
        public ActionResult TicketInfo(TicketInfo ticket)
        {
            var newTicket = new Ticket();
            NewTicketInfo newTicketInfo;
            using (var ctx = new TicketDbContext())
            {
                if (ctx.Tickets.SingleOrDefault(t => t.Seat.Id == ticket.SeatId && t.Event.Id == ticket.EventId) == null)
                {
                    newTicket = new Ticket()
                    {
                        Owner = new Person()
                        {
                            FirstName = ticket.FirstName,
                            LastName = ticket.LastName,
                            MiddleName = ticket.MiddleName
                        },
                        Event = ctx.Events.Find(ticket.EventId),
                        Seat = ctx.Seats.Find(ticket.SeatId)
                    };

                    ctx.Tickets.Add(newTicket);
                    ctx.SaveChanges();

                    newTicketInfo = new NewTicketInfo()
                    {
                        IsSuccessfulOperation = true,
                        TicketId = newTicket.Id,
                        SeatId = newTicket.Seat.Id
                    };
                }
                else
                {
                    newTicketInfo = new NewTicketInfo()
                    {
                        IsSuccessfulOperation = false
                    };
                }
            }

            return Json(newTicketInfo, JsonRequestBehavior.AllowGet);
        }
示例#5
0
        public ActionResult GetEventSectorInfo(int sectorId, int eventId)
        {
            using (var ctx = new TicketDbContext())
            {
                Sector sector = ctx.Sectors.Find(sectorId);
                Event e = ctx.Events.Find(eventId);
                SectorInfo sectorInfo = new SectorInfo()
                {
                    EventId = eventId,
                    EventDate = e.Date.ToString(CultureInfo.InvariantCulture),
                    Price = e.Price,

                    SectorId = sector.Id,
                    RowNumber = sector.RowNumber,
                    SeatNumber = sector.SeatNumber
                };

                return Json(sectorInfo, JsonRequestBehavior.AllowGet);
            }
        }