示例#1
0
        public static int[] GetNumbersOfPlaces(this HtmlHelper helper, int routeId) //Метод, расширяющий хелпер @Html
        {
            List <int> freetickets = new List <int>();
            List <int> busytickets = new List <int>();

            using (WorkWithDatabase db = new WorkWithDatabase())
            {
                int RouteId = routeId;
                var countst = db.GetEntityById <Route, int>(RouteId).MaxNumberOfPlace;
                if (countst > 0)
                {
                    int   countOfPlace = Convert.ToInt32(countst);
                    int[] masplace     = new int[countOfPlace];
                    busytickets = db.GetEntityList <Ticket>().Where(x => x.Route.Id.Equals(RouteId)).Select(x => x.NumberOfPlace).ToList();
                    for (int i = 1; i <= countOfPlace; i++)
                    {
                        if (!busytickets.Contains(i))
                        {
                            freetickets.Add(i);
                        }
                    }
                }
            }
            return(freetickets.ToArray());
        }
示例#2
0
 public ActionResult ReturnTicket(int ticketId)
 {
     using (WorkWithDatabase db = new WorkWithDatabase())
     {
         Ticket tic = db.GetEntityById <Ticket, int>(ticketId);
         tic.IsDeleted = true;
         db.Commit();
     }
     return(RedirectToAction("TicketInformation"));
 }
示例#3
0
 public ActionResult BuyBookTicket(int tickId)
 {
     using (WorkWithDatabase db = new WorkWithDatabase())
     {
         Ticket tick = db.GetEntityById <Ticket, int>(tickId);
         tick.Condition = TypeOfTicketEnum.Bought;
         db.Commit();
     }
     return(RedirectToAction("TicketInformation"));
 }
示例#4
0
 public ActionResult Buy()
 {
     Ticket ticket = new Ticket();
     using (WorkWithDatabase db = new WorkWithDatabase())
     {
         string s = Session[BookTickets.Properties.Resources.RouteID].ToString();
         if (s != null)
         {
             int r = Convert.ToInt32(s);
             var rout = db.GetEntityById<Route, int>(r);
             ticket.Route = rout;
         }
     }
     return View("Buy", ticket);
 }
示例#5
0
        public ActionResult Buy()
        {
            Ticket ticket = new Ticket();

            using (WorkWithDatabase db = new WorkWithDatabase())
            {
                string s = Session[BookTickets.Properties.Resources.RouteID].ToString();
                if (s != null)
                {
                    int r    = Convert.ToInt32(s);
                    var rout = db.GetEntityById <Route, int>(r);
                    ticket.Route = rout;
                }
            }
            return(View("Buy", ticket));
        }
示例#6
0
 public ActionResult Buy(Ticket tick)
 {
     if (tick.NumberOfPlace != 0)
     {
         using (WorkWithDatabase db = new WorkWithDatabase())
         {
             tick.Condition = TypeOfTicketEnum.Bought;
             string s1    = Session[BookTickets.Properties.Resources.LogInUserName].ToString();
             string s2    = Session[BookTickets.Properties.Resources.LogInUserPassword].ToString();
             var    per   = db.GetEntityList <Person>().Where(x => x.LogName.Equals(s1) && x.Password.Equals(s2)).FirstOrDefault();
             var    route = db.GetEntityById <Route, int>(tick.Route.RouteID);
             tick.Person = per;
             tick.Route  = route;
             db.Insert <Ticket>(tick);
             db.Commit();
         }
         return(RedirectToAction("TicketInformation"));
     }
     else
     {
         return(View());
     }
 }
示例#7
0
 public ActionResult Buy(Ticket tick)
 {
     if (tick.NumberOfPlace != 0)
     {
         using (WorkWithDatabase db = new WorkWithDatabase())
         {
             tick.Condition = TypeOfTicketEnum.Bought;
             string s1 = Session[BookTickets.Properties.Resources.LogInUserName].ToString();
             string s2 = Session[BookTickets.Properties.Resources.LogInUserPassword].ToString();
             var per = db.GetEntityList<Person>().Where(x => x.LogName.Equals(s1) && x.Password.Equals(s2)).FirstOrDefault();
             var route = db.GetEntityById<Route, int>(tick.Route.RouteID);
             tick.Person = per;
             tick.Route = route;
             db.Insert<Ticket>(tick);
             db.Commit();
         }
         return RedirectToAction("TicketInformation");
     }
     else
     {
         return View();
     }
 }
示例#8
0
        public static int[] GetNumbersOfPlaces(this HtmlHelper helper, int routeId)//Метод, расширяющий хелпер @Html
        {
            List<int> freetickets = new List<int>();
            List<int> busytickets = new List<int>();
            using (WorkWithDatabase db = new WorkWithDatabase())
            {
                int RouteId = routeId;
                var countst = db.GetEntityById<Route, int>(RouteId).MaxNumberOfPlace;
                if (countst > 0)
                {
                    int countOfPlace = Convert.ToInt32(countst);
                    int[] masplace = new int[countOfPlace];
                    busytickets = db.GetEntityList<Ticket>().Where(x => x.Route.Id.Equals(RouteId)).Select(x => x.NumberOfPlace).ToList();
                    for (int i = 1; i <= countOfPlace; i++)
                    {
                        if (!busytickets.Contains(i)) { freetickets.Add(i); }
                    }
                }

            }
            return freetickets.ToArray();
        }
示例#9
0
 public ActionResult ReturnTicket(int ticketId)
 {
     using (WorkWithDatabase db = new WorkWithDatabase())
     {
         Ticket tic = db.GetEntityById<Ticket, int>(ticketId);
         tic.IsDeleted = true;
         db.Commit();
     }
     return RedirectToAction("TicketInformation");
 }
示例#10
0
 public ActionResult BuyBookTicket(int tickId)
 {
     using (WorkWithDatabase db = new WorkWithDatabase())
     {
         Ticket tick = db.GetEntityById<Ticket, int>(tickId);
         tick.Condition = TypeOfTicketEnum.Bought;
         db.Commit();
     }
     return RedirectToAction("TicketInformation");
 }