Esempio n. 1
0
        //Shop items UI
        public ActionResult AdminPanel()
        {
            if (!HttpContext.Request.Cookies.AllKeys.Contains("authOk"))
            {
                return(RedirectToAction("Validation", "AdminPage"));
            }

            AdminUIHelper helper = new AdminUIHelper(itemService);
            var           map    = helper.MapDTOWithViewModel();

            return(View(map));
        }
Esempio n. 2
0
        public ActionResult DeleteItem(int id)
        {
            AdminUIHelper helper = new AdminUIHelper(itemService);

            var    model      = itemService.Get(id);
            string shortPath  = model.PhotoPath;
            string serverPath = Request.MapPath(helper.GetFullserverPath(id));

            helper.DeleteImageOnServer(serverPath, shortPath);
            helper.DeleteItemFromServer(id);

            return(RedirectToAction("AdminPanel"));
        }
Esempio n. 3
0
        public ActionResult Create(ShopItemViewModel context, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                AdminUIHelper helper = new AdminUIHelper(itemService);

                string serverImgPath = Path.Combine(Server.MapPath("~/Images"), helper.GetFullImageName(image));
                image.SaveAs(serverImgPath);

                string modelPath = "~/Images/" + helper.GetFullImageName(image);

                helper.CreateItemOnServer(context, modelPath);

                return(RedirectToAction("AdminPanel"));
            }

            return(View());
        }
Esempio n. 4
0
        public ActionResult Edit([Bind(Include = "Id,Name,Description,Price,PhotoPath")] ShopItemViewModel context, HttpPostedFileBase image)
        {
            AdminUIHelper helper = new AdminUIHelper(itemService);

            string modelPath = context.PhotoPath;

            if (image != null)
            {
                string serverImgPath = Path.Combine(Server.MapPath("~/Images"), helper.GetFullImageName(image));
                image.SaveAs(serverImgPath);

                string deletePath = Request.MapPath(helper.GetFullserverPath(context.Id));
                helper.DeleteImageOnServer(deletePath);

                modelPath = "~/Images/" + helper.GetFullImageName(image);
            }

            helper.EditItemOnServer(context, modelPath);

            return(RedirectToAction("AdminPanel"));
        }
Esempio n. 5
0
        //Delete/Edit current item page
        public ActionResult DeleteItem(int?id)
        {
            AdminUIHelper helper = new AdminUIHelper(itemService);

            return(View(helper.GetCurrentUser(id)));
        }