Ejemplo n.º 1
0
        public IActionResult <IEnumerable <string> > Categories(HttpSession session)
        {
            AuthenticatedManager.GetAuthenticatedUser(session.Id);
            IEnumerable <string> categoryNames = this.service.GetCategoryNames();

            return(this.View(categoryNames));
        }
Ejemplo n.º 2
0
        public IActionResult <IEnumerable <TopicViewModel> > Topics(HttpSession session)
        {
            AuthenticatedManager.GetAuthenticatedUser(session.Id);
            IEnumerable <TopicViewModel> topics = service.GetTopTenLatestTopics();

            return(this.View(topics));
        }
Ejemplo n.º 3
0
 public IActionResult Add(HttpResponse response, HttpSession session)
 {
     if (!AuthenticatedManager.IsAdmin(session.Id))
     {
         this.Redirect(response, "/user/login");
     }
     return(this.View());
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 5
0
 private bool IsAuthenticated(string sessionId, HttpResponse response)
 {
     if (AuthenticatedManager.IsAuthenticated(sessionId))
     {
         this.Redirect(response, "/home/topics");
         return(true);
     }
     return(false);
 }
Ejemplo n.º 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());
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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"));
        }
Ejemplo n.º 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));
        }