Пример #1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                Excursion.Data.User user = userRepository.FindOne(x => x.Login == model.UserName);
                if (user != null && user.Password == model.Password)
                {
                    HttpContext.Session["CurrentUser"] = user;

                    if (SessionData.CurrentUser.TypeUser == "Client Indirect" || SessionData.CurrentUser.TypeUser == "Responsable Service Excursions")
                    {
                        if (cartRepository.GetAll() != null)
                        {
                            foreach (Cart cart in cartRepository.GetAll().ToList())
                            {
                                cartRepository.Delete(cart);
                                cartRepository.Save();
                            }
                        }

                        return(RedirectToAction("Index", new RouteValueDictionary(
                                                    new { controller = "Reservation", action = "Index" })));
                    }
                    //else if (SessionData.CurrentUser.TypeUser == "Responsable Service Excursions")
                    //{
                    //    return RedirectToAction("Index", new RouteValueDictionary(
                    //              new { controller = "Reservation", action = "Index" }));
                    //}
                    else
                    {
                        return(RedirectToAction("Index", new RouteValueDictionary(
                                                    new { controller = "Excursion", action = "Index", UserID = SessionData.CurrentUser.UserID })));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                    return(View(model));
                }

                //return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return(View(model));
        }
Пример #2
0
        public ActionResult Index(int UserID)
        {
            Excursion.Data.User user = userRepository.FindOne(x => x.UserID == UserID);

            if (user.TypeUser == "Responsable")
            {
                if (user.RoleResp == "RespExcSSE")
                {
                    centreID = 1;
                }
                else if (user.RoleResp == "RespExcHMT")
                {
                    centreID = 2;
                }
                else if (user.RoleResp == "RespExcDJE")
                {
                    centreID = 3;
                }
            }
            else if (user.TypeUser == "Client Indirect" && user.CentreID != null)
            {
                centreID = (int)user.CentreID;
            }

            List <Excursion.Data.Excursion> ListExc = excursionRepository.FindMany(x => x.CentreID == centreID).ToList();

            if (ListExc.Count != 0)
            {
                return(View(ListExc));
            }
            else
            {
                ViewBag.Message = "There's no outings";
                return(View());
            }
        }