예제 #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));
        }
예제 #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"));
        }
예제 #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());
        }
예제 #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"));
        }
예제 #5
0
        //Delete/Edit current item page
        public ActionResult DeleteItem(int?id)
        {
            AdminUIHelper helper = new AdminUIHelper(itemService);

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