Пример #1
0
 private bool IsAuthenticated(string sessionId, HttpResponse response)
 {
     if (AuthenticatedManager.IsAuthenticated(sessionId))
     {
         this.Redirect(response, "/home/topics");
         return(true);
     }
     return(false);
 }
Пример #2
0
        public ActionResult Login()
        {
            var httpCookies = this.Request.Cookies.Get("sessionId");

            if (httpCookies != null && AuthenticatedManager.IsAuthenticated(httpCookies.Value))
            {
                return(this.RedirectToAction("All", "Cars"));
            }
            return(View());
        }
Пример #3
0
        public ActionResult AddConfirmation(AddSalesConfirmationViewModel vm)
        {
            var cookie = this.Request.Cookies.Get("sessionId");

            if (cookie == null || !AuthenticatedManager.IsAuthenticated(cookie.Value))
            {
                return(this.RedirectToAction("Login", "Users"));
            }
            return(View(vm));
        }
Пример #4
0
        public ActionResult Add()
        {
            var httpCookies = this.Request.Cookies.Get("sessionId");

            if (httpCookies == null || !AuthenticatedManager.IsAuthenticated(httpCookies.Value))
            {
                return(this.RedirectToAction("All"));
            }
            return(this.View());
        }
Пример #5
0
        public void Buy(HttpResponse response, HttpSession session, BuyGameBindingModel bind)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/user/login");
            }
            User currentUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            this.service.BuyGameForUser(currentUser, bind);
            this.Redirect(response, "/home/games?filter=owned");
        }
Пример #6
0
        public ActionResult Logout()
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value))
            {
                return(this.RedirectToAction("Login"));
            }
            AuthenticatedManager.Logout(Request.Cookies.Get("sessionId").Value);
            return(this.RedirectToAction("All", "Cars"));
        }
Пример #7
0
        public ActionResult AddConfirmation(AddSaleBindingModel bind)
        {
            var cookie = this.Request.Cookies.Get("sessionId");

            if (cookie == null || !AuthenticatedManager.IsAuthenticated(cookie.Value))
            {
                return(this.RedirectToAction("Login", "Users"));
            }
            this.service.AddSale(bind);
            return(this.RedirectToAction("All"));
        }
Пример #8
0
        public IActionResult <GameDetailsViewModel> Info(HttpSession session, HttpResponse response, int id)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/user/login");
                return(null);
            }
            GameDetailsViewModel model = this.service.GetGameDetailsViewModel(id);

            return(this.View(model));
        }
Пример #9
0
        public ActionResult All(string username, int?page)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value))
            {
                return(this.RedirectToAction("All", "Suppliers"));
            }
            AllLogsPageViewModel vm = this.service.GetAllLogsPageVm(username, page);

            return(View(vm));
        }
Пример #10
0
        public IActionResult <AllViewModel> Games(HttpSession session, HttpResponse response, string filter)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/user/login");
                return(null);
            }
            User currentUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);
            var  model       = this.service.GetAllViewModel(filter, currentUser);

            return(this.View(model));
        }
Пример #11
0
        public ActionResult Add()
        {
            var cookie = this.Request.Cookies.Get("sessionId");

            if (cookie == null || !AuthenticatedManager.IsAuthenticated(cookie.Value))
            {
                return(this.RedirectToAction("Login", "Users"));
            }
            AddSaleViewModel vm = this.service.GetSalesViewModel();

            return(View(vm));
        }
Пример #12
0
        public ActionResult DeleteAlll()
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value))
            {
                return(this.RedirectToAction("All", "Suppliers"));
            }

            this.service.DeleteAllLogs();
            return(this.RedirectToAction("All", "Suppliers"));
        }
Пример #13
0
        public ActionResult Add([Bind(Include = "Name,IsImporter")] AddSupplierBindingModel bind)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value))
            {
                return(this.RedirectToAction("All"));
            }
            User loggedInUser = AuthenticatedManager.GetAuthenticatedUsers(httpCookie.Value);

            this.service.AddSupplier(bind, loggedInUser.Id);
            return(this.RedirectToAction("All"));
        }
Пример #14
0
        public ActionResult Edit(int id)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value))
            {
                return(this.RedirectToAction("All"));
            }

            EditSupplierViewModel vm = this.service.GetEditSupplierVm(id);

            return(this.View(vm));
        }
Пример #15
0
        public ActionResult Register([Bind(Include = "Username, Email, Password, ConfirmPassword")] RegisterUserBindingModel bind)
        {
            var httpCookies = this.Request.Cookies.Get("sessionId");

            if (httpCookies != null && AuthenticatedManager.IsAuthenticated(httpCookies.Value))
            {
                return(this.RedirectToAction("All", "Cars"));
            }
            if (this.ModelState.IsValid && bind.Password == bind.ConfirmPassword)
            {
                this.service.RegisterUser(bind);
                return(this.RedirectToAction("Login"));
            }
            return(this.RedirectToAction("Register"));
        }
Пример #16
0
        public IActionResult <AllAdminGameViewModel> Managing(HttpSession session, HttpResponse response)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/user/login");
                return(null);
            }
            if (!AuthenticatedManager.IsAdmin(session.Id))
            {
                this.Redirect(response, "/home/games");
                return(null);
            }
            var model = this.service.GetAllAdminViewModel();

            return(this.View(model));
        }
Пример #17
0
        public void Delete(HttpResponse response, HttpSession session, int id)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/forum/login");
            }

            User activeUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (!activeUser.IsAdmin)
            {
                this.Redirect(response, "/home/topics");
            }

            this.service.DeleteCategory(id);
            this.Redirect(response, "/categories/all");
        }
Пример #18
0
        public ActionResult Login([Bind(Include = "Username, Password")] LoginBindingModel bind)
        {
            var httpCookies = this.Request.Cookies.Get("sessionId");

            if (httpCookies != null && AuthenticatedManager.IsAuthenticated(httpCookies.Value))
            {
                return(this.RedirectToAction("All", "Cars"));
            }

            if (this.ModelState.IsValid && this.service.IsUserExists(bind))
            {
                this.service.LoginUser(bind, Session.SessionID);
                this.Response.SetCookie(new HttpCookie("sessionId", Session.SessionID));
                return(this.RedirectToAction("All", "Cars"));
            }
            return(this.RedirectToAction("Login"));
        }
Пример #19
0
        public ActionResult All(string supplyerType)
        {
            var httpCookies = this.Request.Cookies.Get("sessionId");

            if (httpCookies == null || !AuthenticatedManager.IsAuthenticated(httpCookies.Value))
            {
                IEnumerable <SupplierViewModel> supplies = this.service.GetAllSuplyersByType(supplyerType);
                return(this.View(supplies));
            }

            User user = AuthenticatedManager.GetAuthenticatedUsers(httpCookies.Value);

            ViewBag.Username = user.Username;
            IEnumerable <SuplierAllViewModel> vm = this.service.GetAllSupplierByTypeForUser(supplyerType);

            return(View("AllSuppliersForUser", vm));
        }
Пример #20
0
        public IActionResult <EditCategoryViewModel> Edit(HttpResponse response, HttpSession session, int id)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/forum/login");
            }

            User activeUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (!activeUser.IsAdmin)
            {
                this.Redirect(response, "/home/topics");
            }

            EditCategoryViewModel viewModel = this.service.GetEditCategoryVM(id);

            return(this.View(viewModel));
        }
Пример #21
0
        public ActionResult Add([Bind(Include = "Make, Model, TravelledDistance, Parts")] AddCarBindingModel bind)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value))
            {
                return(this.RedirectToAction("Login", "Users"));
            }

            if (this.ModelState.IsValid)
            {
                this.service.AddCar(bind);

                return(this.RedirectToAction("All"));
            }

            return(this.View());
        }
Пример #22
0
        public IActionResult New(HttpResponse response, HttpSession session)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/forum/login");
                return(null);
            }

            User activeUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (!activeUser.IsAdmin)
            {
                this.Redirect(response, "/home/topics");
                return(null);
            }

            return(this.View());
        }
Пример #23
0
        public IActionResult <EditCategoryViewModel> Edit(HttpResponse response, HttpSession session, EditCategoryBindingModel bind)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/forum/login");
            }

            User activeUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (!activeUser.IsAdmin)
            {
                this.Redirect(response, "/home/topics");
            }

            this.service.EditCategoryEntity(bind);
            this.Redirect(response, "/categories/all");
            return(null);
        }
Пример #24
0
        public IActionResult <AllViewModel> All(HttpSession session, HttpResponse response)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/forum/login");
                return(null);
            }

            User activeUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (!activeUser.IsAdmin)
            {
                this.Redirect(response, "/home/topics");
                return(null);
            }
            AllViewModel model = this.service.GetAllViewModel(activeUser);

            return(this.View(model));
        }
Пример #25
0
        public ActionResult Delete([Bind(Include = "Id")] DeleteSupplierBindingModel bind)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie == null || !AuthenticatedManager.IsAuthenticated(httpCookie.Value))
            {
                return(this.RedirectToAction("All"));
            }

            if (!this.ModelState.IsValid)
            {
                DeleteSuplierViewModel vm = this.service.GetDeleteSupplierVm(bind.Id);
                return(this.View(vm));
            }

            User loggedInUser = AuthenticatedManager.GetAuthenticatedUsers(httpCookie.Value);

            this.service.DeleteSupplier(bind, loggedInUser.Id);
            return(this.RedirectToAction("All"));
        }
Пример #26
0
        public void New(HttpResponse response, HttpSession session, NewCategoryBindingModel model)
        {
            if (!AuthenticatedManager.IsAuthenticated(session.Id))
            {
                this.Redirect(response, "/forum/login");
            }

            User activeUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (!activeUser.IsAdmin)
            {
                this.Redirect(response, "/home/topics");
            }

            if (!this.service.IsNewCategoryValid(model))
            {
                this.Redirect(response, "/categories/new");
            }
            //Category category = this.service.GetCategoryFromBind(model);
            this.service.AddNewCategory(model);
            this.Redirect(response, "/categories/all");
        }