Exemple #1
0
        public ActionResult TicketInformation()
        {
            List <Ticket> tickets = new List <Ticket>();

            using (WorkWithDatabase db = new WorkWithDatabase())
            {
                string s1 = Session[BookTickets.Properties.Resources.LogInUserName].ToString();
                string s2 = Session[BookTickets.Properties.Resources.LogInUserPassword].ToString();
                var    t  = db.GetEntityList <Person>().Where(x => x.LogName.Equals(s1) && x.Password.Equals(s2)).Select(x => x.PersonID).FirstOrDefault();

                tickets = db.GetEntityList <Ticket>().Where(x => x.Person.PersonID.Equals(t)).ToList();
            }
            return(View("InformationAboutTicket", tickets));
        }
Exemple #2
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());
        }
 public ActionResult Index()
 {
     List<Route> Listroutes = new List<Route>();
     using (WorkWithDatabase db = new WorkWithDatabase())
     {
         Listroutes = db.GetEntityList<Route>();
     }
     return View(Listroutes);
 }
Exemple #4
0
        public ActionResult Index()
        {
            List <Route> Listroutes = new List <Route>();

            using (WorkWithDatabase db = new WorkWithDatabase())
            {
                Listroutes = db.GetEntityList <Route>();
            }
            return(View(Listroutes));
        }
Exemple #5
0
 private bool check(string name, string pass)
 {
     using (WorkWithDatabase db = new WorkWithDatabase())
     {
         try
         {
             return(db.GetEntityList <Person>().Where(x => x.LogName.Equals(name) && x.Password.Equals(pass)).Count() > 0);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Exemple #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());
     }
 }
 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();
     }
 }
        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();
        }
 private bool check(string name, string pass)
 {
     using (WorkWithDatabase db = new WorkWithDatabase())
     {
         try
         {
             return db.GetEntityList<Person>().Where(x => x.LogName.Equals(name) && x.Password.Equals(pass)).Count() > 0;
         }
         catch (Exception ex)
         {
             return false;
         }
     }
 }
        public ActionResult TicketInformation()
        {
            List<Ticket> tickets = new List<Ticket>();
            using (WorkWithDatabase db = new WorkWithDatabase())
            {
                string s1 = Session[BookTickets.Properties.Resources.LogInUserName].ToString();
                string s2 = Session[BookTickets.Properties.Resources.LogInUserPassword].ToString();
                var t = db.GetEntityList<Person>().Where(x => x.LogName.Equals(s1) && x.Password.Equals(s2)).Select(x => x.PersonID).FirstOrDefault();

                tickets = db.GetEntityList<Ticket>().Where(x => x.Person.PersonID.Equals(t)).ToList();
            }
            return View("InformationAboutTicket", tickets);
        }