Beispiel #1
0
        public ActionResult Autorize(string login, string password)
        {
            if (login == "Moderator" & password == "gfhjkm")
            {
                HttpCookie cookie = new HttpCookie("Role", "Moder");
                cookie.Expires = DateTime.Now.AddMinutes(10);

                Response.Cookies.Add(cookie);

                return(RedirectToAction("AllVihecles"));
            }
            else if (DataAccesLayer.LogIn(login, password))
            {
                HttpCookie cookie = new HttpCookie("Role", "Moder");
                cookie.Expires = DateTime.Now.AddMinutes(10);

                Response.Cookies.Add(cookie);

                return(RedirectToAction("AllVihecles"));
            }

            ViewBag.Message = "Не верный логин или пароль";

            return(View());
        }
Beispiel #2
0
        public ActionResult Delete(Vehicle model, string del)
        {
            bool isHiden = true;

            if (Request.Cookies["Role"] != null)
            {
                if (Request.Cookies["Role"].Value == "Moder")
                {
                    isHiden = false;
                }
                else
                {
                    isHiden         = true;
                    ViewBag.Message = "У вас недостаточно прав";
                }
            }
            if (!isHiden)
            {
                if (DataAccesLayer.Delete(model.VehicleId))
                {
                    return(RedirectToAction("AllVihecles"));
                }
                ViewBag.Message = "Не удалено";
            }
            return(View(model));
        }
Beispiel #3
0
        public ActionResult AllVihecles(string filter, string filtType, string isInGarage, string isInRepair, string isIsWork)
        {
            IEnumerable <Vehicle> vehicles = DataAccesLayer.GetVehicles();

            bool[] state = new bool[3];

            if (filtType == "Filt by TypeId")
            {
                vehicles = vehicles.Where(x => x.TypeId.ToLower().Contains(filter.ToLower()));
            }
            else if (filtType == "Filt by Name")
            {
                vehicles = vehicles.Where(x => x.Name.ToLower().Contains(filter.ToLower()));
            }

            if (isInGarage != "" & isInGarage != null)
            {
                state[0] = true;
            }
            else
            {
                state[0] = false;
            }

            if (isInRepair != "" & isInRepair != null)
            {
                state[1] = true;
            }
            else
            {
                state[1] = false;
            }

            if (isIsWork != "" & isIsWork != null)
            {
                state[2] = true;
            }
            else
            {
                state[2] = false;
            }

            vehicles = vehicles.Where(x => x.InGarage & state[0] || x.InRepair & state[1] || x.IsWork & state[2]);

            return(View(vehicles));
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            ConnectionFactory connecfactory  = new ConnectionFactory();
            ParserLocation    parserLocation = new ParserLocation();
            DataAccesLayer    dataAccesLayer = new DataAccesLayer();


            connecfactory.HostName = "localhost";
            using (var connection = connecfactory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare("hello", durable: false, false, false, null);

                    channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);
                    // mesaj 1 tane gelsin doğru işlenirse 1 tane daha gönder
                    // diğer insantaların aldığınıda hesaba katmak için global=true yapılır. ama benim tercihim false yönünde
                    Console.WriteLine("Mesajları bekliyoum");


                    var consumer = new EventingBasicConsumer(channel);

                    channel.BasicConsume("hello", autoAck: false, consumer);// autoAck:false, silinmemesi için false yapmak gerekir.

                    consumer.Received += (model, e) =>
                    {
                        // int time = Convert.ToInt32(GetMessage(args));
                        // int time = 200;
                        //Thread.Sleep(1000);

                        var result = parserLocation.GetParser(e.Body);


                        dataAccesLayer.Add((Location)result);


                        channel.BasicAck(deliveryTag: e.DeliveryTag, multiple: false);
                        // mesaj başarıyla işledim kuyruktan silebilirsin anlamına geliyor.
                    };
                    Console.WriteLine("Çıkmak için tıklayınız");
                    Console.ReadLine();
                }
            }
        }
Beispiel #5
0
        public ActionResult Create(Vehicle model)
        {
            bool isHiden = true;

            if (Request.Cookies["Role"] != null)
            {
                if (Request.Cookies["Role"].Value == "Moder")
                {
                    isHiden = false;
                }
                else
                {
                    isHiden         = true;
                    ViewBag.Message = "У вас недостаточно прав";
                }
            }

            if (!isHiden)
            {
                if (ModelState.IsValid & IsValidVehicles(model))
                {
                    if (DataAccesLayer.Add(model))
                    {
                        ViewBag.Message = "Добавлено";
                    }
                    else
                    {
                        ViewBag.Message = "Введите корректные данные";
                    }
                }
                else
                {
                    ViewBag.Message = "Введите корректные данные";
                }
            }
            return(View(model));
        }
Beispiel #6
0
        public ActionResult Edit(Vehicle model, string save)
        {
            bool isHiden = true;

            if (Request.Cookies["Role"] != null)
            {
                if (Request.Cookies["Role"].Value == "Moder")
                {
                    isHiden = false;
                }
                else
                {
                    isHiden         = true;
                    ViewBag.Message = "У вас недостаточно прав";
                }
            }
            if (!isHiden)
            {
                if (ModelState.IsValid & IsValidVehicles(model))
                {
                    if (DataAccesLayer.Edit(model))
                    {
                        ViewBag.Message = "Изменено";
                    }
                    else
                    {
                        ViewBag.Message = "Не Изменено";
                    }
                }
                else
                {
                    ViewBag.Message = "Не Изменено";
                }
            }
            return(View(model));
        }
Beispiel #7
0
 public GuideController(DataAccesLayer dataAccesLayer)
 {
     this.dataAccessLayer = dataAccesLayer;
 }
Beispiel #8
0
 public ActionResult AllVihecles()
 {
     return(View(DataAccesLayer.GetVehicles()));
 }
Beispiel #9
0
 public UserController(DataAccesLayer usersDataAccesLayer)
 {
     this.usersDataAccessLayer = usersDataAccesLayer;
 }
 public PhotographerVerificationController(DataAccesLayer dataAccesLayer)
 {
     this.dataAccesLayer = dataAccesLayer;
 }
Beispiel #11
0
 public CarController(DataAccesLayer dataAccesLayer)
 {
     this.dataAccesLayer = dataAccesLayer;
 }
Beispiel #12
0
 public GuideVerificationController(DataAccesLayer dataAccesLayer)
 {
     this.dataAccesLayer = dataAccesLayer;
 }
 public DriverVerificationController(DataAccesLayer dataAccesLayer)
 {
     this.dataAccesLayer = dataAccesLayer;
 }
Beispiel #14
0
 public PhotographerController(DataAccesLayer users)
 {
     this.usersDataAccessLayer = users;
 }