public ActionResult Delete(int?id)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

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

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var user = AuthenticationManager.GetUser(httpCookie.Value);

            ViewBag.Username = user.Username;

            var viewModel = this.service.GetDeleteCameraVm(id);

            if (viewModel == null)
            {
                return(new HttpNotFoundResult("NO CAMERA WITH THIS ID!!!"));
            }

            return(this.View(viewModel));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

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

            this.service.DeleteCamera(id);

            return(this.RedirectToAction("Profile", "Users"));
        }
        public ActionResult All()
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie != null && AuthenticationManager.IsAuthenticated(httpCookie.Value))
            {
                var user = AuthenticationManager.GetUser(httpCookie.Value);
                ViewBag.Username = user.Username;
            }

            var viewModels = this.service.GetAllCamerasVms();

            return(View(viewModels));
        }
        public ActionResult Add()
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

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

            var user = AuthenticationManager.GetUser(httpCookie.Value);

            ViewBag.Username = user.Username;

            return(this.View());
        }
        public ActionResult Add([Bind(Exclude = "")] AddCameraBm model)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

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

            var user = AuthenticationManager.GetUser(httpCookie.Value);

            ViewBag.Username = user.Username;

            if (this.ModelState.IsValid)
            {
                this.service.AddCameraFromBm(model, user);
                return(this.RedirectToAction("All", "Cameras"));
            }

            var viewModel = Mapper.Map <AddCameraBm, AddCameraVm>(model);

            return(this.View(viewModel));
        }
        public ActionResult Edit([Bind(Exclude = "")] EditCameraBm model)
        {
            var httpCookie = this.Request.Cookies.Get("sessionId");

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

            var user = AuthenticationManager.GetUser(httpCookie.Value);

            ViewBag.Username = user.Username;

            if (this.ModelState.IsValid)
            {
                this.service.EditCameraFromBm(model);
                return(this.RedirectToAction("Profile", "Users"));
            }

            var viewModel = this.service.GetEditCameraVm(model.Id);

            return(this.View(viewModel));
        }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var httpCookie = this.Request.Cookies.Get("sessionId");

            if (httpCookie != null)
            {
                var user = AuthenticationManager.GetUser(httpCookie.Value);
                ViewBag.Username = user.Username;
            }

            var viewModel = this.service.GetCameraDetailsVm(id);

            if (viewModel == null)
            {
                return(new HttpNotFoundResult("NO CAMERA WITH THIS ID!!!"));
            }

            return(this.View(viewModel));
        }