Пример #1
0
        public IActionResult <IEnumerable <string> > Categories(HttpSession session)
        {
            AuthenticatedManager.GetAuthenticatedUser(session.Id);
            IEnumerable <string> categoryNames = this.service.GetCategoryNames();

            return(this.View(categoryNames));
        }
Пример #2
0
        public IActionResult <IEnumerable <TopicViewModel> > Topics(HttpSession session)
        {
            AuthenticatedManager.GetAuthenticatedUser(session.Id);
            IEnumerable <TopicViewModel> topics = service.GetTopTenLatestTopics();

            return(this.View(topics));
        }
Пример #3
0
 public IActionResult Add(HttpResponse response, HttpSession session)
 {
     if (!AuthenticatedManager.IsAdmin(session.Id))
     {
         this.Redirect(response, "/user/login");
     }
     return(this.View());
 }
Пример #4
0
        public IActionResult <IEnumerable <TopicViewModel> > Topics(HttpSession session, string categoryName)
        {
            AuthenticatedManager.GetAuthenticatedUser(session.Id);

            IEnumerable <TopicViewModel> topics = this.service.GetCategoryTopicsViewModels(categoryName);

            return(this.View(topics));
        }
Пример #5
0
 private bool IsAuthenticated(string sessionId, HttpResponse response)
 {
     if (AuthenticatedManager.IsAuthenticated(sessionId))
     {
         this.Redirect(response, "/home/topics");
         return(true);
     }
     return(false);
 }
Пример #6
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());
        }
Пример #7
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));
        }
Пример #8
0
        public void Edit(HttpResponse response, HttpSession session, EditGameBindingModel bind)
        {
            if (!AuthenticatedManager.IsAdmin(session.Id))
            {
                this.Redirect(response, "/user/login");
            }

            this.service.EditGame(bind);
            this.Redirect(response, "/game/managing");
        }
Пример #9
0
        public void Delete(HttpResponse response, HttpSession session, DeleteViewModel bind)
        {
            if (!AuthenticatedManager.IsAdmin(session.Id))
            {
                this.Redirect(response, "/user/login");
            }

            this.service.Delete(bind.Id);
            this.Redirect(response, "/game/managing");
        }
Пример #10
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());
        }
Пример #11
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");
        }
Пример #12
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"));
        }
Пример #13
0
        public IActionResult <EditViewModel> Edit(HttpResponse response, HttpSession session, int id)
        {
            if (!AuthenticatedManager.IsAdmin(session.Id))
            {
                this.Redirect(response, "/user/login");
            }

            EditViewModel model = this.service.GetEditViewModel(id);

            return(this.View(model));
        }
Пример #14
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"));
        }
Пример #15
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));
        }
Пример #16
0
        public void Info(HttpSession session, HttpResponse response, GameDetailsViewModel model)
        {
            User user = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (user == null)
            {
                this.Redirect(response, "/home/games");
                return;;
            }
            this.service.GetGameFromViewModel(model);
        }
Пример #17
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));
        }
Пример #18
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));
        }
Пример #19
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"));
        }
Пример #20
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));
        }
Пример #21
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"));
        }
Пример #22
0
        public void Details(HttpRequest request, HttpSession session, HttpResponse response, DetailsReplyBindingModel bind)
        {
            User user = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (user == null)
            {
                this.Redirect(response, "/home/topics");
                return;
            }

            this.service.AddNewReply(bind, user);
            this.Redirect(response, request.Url);
        }
Пример #23
0
        public IActionResult <IEnumerable <string> > New(HttpSession session, HttpResponse response)
        {
            User currentUser = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (currentUser == null)
            {
                this.Redirect(response, "/home/topics");
            }

            IEnumerable <string> categoryName = this.service.GetCategoryNames();

            return(this.View(categoryName));
        }
Пример #24
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));
        }
Пример #25
0
        public IActionResult <DetailsViewModel> Details(int id, HttpSession session, HttpResponse response)
        {
            User user = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            if (user == null)
            {
                this.Redirect(response, "/home/topics");
                return(null);
            }

            DetailsViewModel viewModel = this.service.GetDetailsViewModel(id);

            return(this.View(viewModel));
        }
Пример #26
0
        public IActionResult <ProfileViewModel> Profile(HttpSession session, int id)
        {
            User user = AuthenticatedManager.GetAuthenticatedUser(session.Id);

            int currentUser = -1;

            if (user != null)
            {
                currentUser = user.Id;
            }
            ProfileViewModel topics = this.service.GetProfileViewModel(id, currentUser);

            return(this.View(topics));
        }
Пример #27
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"));
        }
Пример #28
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));
        }
Пример #29
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"));
        }
Пример #30
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));
        }