public void BuyTickets(HttpContext context) { string ticketType = context.Request["ticketType"]; string beginning = context.Request["beginning"]; string destination = context.Request["destination"]; Tickets ticket = SimpleTicketFactory.CreateTicket(ticketType, beginning, destination); ticket.ID = int.Parse(context.Request["id"]); List <string> lstSeats = mgr.BuyTicket(ticket, int.Parse(context.Request["count"])); if (lstSeats != null) { StringBuilder builder = new StringBuilder("["); foreach (string item in lstSeats) { builder.Append("{\"seat\":\"" + item + "\"},"); } context.Response.Write(builder.ToString().Substring(0, builder.ToString().Length - 1) + "]"); } else { context.Response.Write("[]"); } }
public void AddTickets(HttpContext context) { string ticketType = context.Request["ticketType"]; string beginning = context.Request["beginning"]; string destination = context.Request["destination"]; Tickets ticket = SimpleTicketFactory.CreateTicket(ticketType, beginning, destination); ticket.Remainder = int.Parse(context.Request["count"]); if (mgr.Add(ticket)) { context.Response.Write("{\"status\":true}"); } else { context.Response.Write("{\"status\":false}"); } }