Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "id_role,name_role")] Role role)
        {
            if (ModelState.IsValid)
            {
                db.Roles.Add(role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(role));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "id_train,type_train_id")] Train train)
        {
            if (ModelState.IsValid)
            {
                db.Trains.Add(train);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.type_train_id = new SelectList(db.Type_train, "id_type_train", "name_type", train.type_train_id);
            return(View(train));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "id_client,surname,name,patronymic,pass,login,password,role_id")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.role_id = new SelectList(db.Roles, "id_role", "name_role", client.role_id);
            return(View(client));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "id_reys,train_id,start_point,end_point,start_date,end_date")] Rey rey)
        {
            if (ModelState.IsValid)
            {
                db.Reys.Add(rey);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.train_id = new SelectList(db.Trains, "id_train", "id_train", rey.train_id);
            return(View(rey));
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "id_place,wagon_id")] Place place)
        {
            if (ModelState.IsValid)
            {
                db.Places.Add(place);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.wagon_id = new SelectList(db.Wagons, "id_wagon", "id_wagon", place.wagon_id);
            return(View(place));
        }
Exemplo n.º 6
0
        public ActionResult Pay(int id)
        {
            var reserve = db.Reservations.Where(c => c.id_reservation == id).FirstOrDefault();

            if (reserve.status_reservation_id == 2)
            {
                reserve.status_reservation_id = 1;
                db.SaveChanges();
                return(View());
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 7
0
        public ActionResult AddToReserve(int id)
        {
            var tick = db.Tickets.Where(c => c.id_ticket == id).FirstOrDefault();

            tick.status_ticket_id = 2;
            string currentUserName = User.Identity.Name;
            Client client          = db.Clients.FirstOrDefault(x => x.login == currentUserName);

            db.Reservations.Add(new Reservation {
                ticket_id = id, date_reservation = DateTime.Now, client_id = client.id_client, status_reservation_id = 2
            });
            db.SaveChanges();

            return(View());
        }
Exemplo n.º 8
0
        private void DeleteRes(object obj)
        {
            lock (synclock)
            {
                CashDeskEntities db = new CashDeskEntities();
                var reservations    = db.Reservations.Include(r => r.Client).Include(r => r.Status_res).Include(r => r.Ticket);

                foreach (var item in reservations.ToList())
                {
                    if (DateTime.Now >= (item.date_reservation).AddDays(1))
                    {
                        var tick = db.Tickets.Where(c => c.id_ticket == item.ticket_id).FirstOrDefault();
                        tick.status_ticket_id = 1;
                        db.Reservations.Remove(item);
                        db.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 9
0
        public ActionResult Register(Client model)
        {
            if (ModelState.IsValid)
            {
                Client client = null;
                using (CashDeskEntities db = new CashDeskEntities())
                {
                    client = db.Clients.FirstOrDefault(u => u.login == model.login);
                }
                if (client == null)
                {
                    using (CashDeskEntities db = new CashDeskEntities())
                    {
                        db.Clients.Add(new Client
                        {
                            surname    = model.surname,
                            name       = model.name,
                            patronymic = model.patronymic,
                            pass       = model.pass,
                            login      = model.login,
                            password   = model.password,
                            role_id    = 3
                        });
                        db.SaveChanges();

                        client = db.Clients.Where(u => u.login == model.login && u.password == model.password).FirstOrDefault();
                    }
                    if (client != null)
                    {
                        FormsAuthentication.SetAuthCookie(model.login, true);
                        return(RedirectToAction("Index", "Reys"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Пользователь с таким логином уже существует!");
                }
            }
            return(View(model));
        }