public ActionResult UpLoad(ProductUploadViewModel p)
        {
            if (ModelState.IsValid)
            {
                DataTransferLayer.Accounts.User u = WebApiHelper.
                    GetUserFromServer("api/accountManager/account/search/" + User.Identity.Name, Method.GET);

                if (u != null)
                {
                    ProductApi np = new ProductApi();
                    np.Name = p.ProductName;
                    np.CategoryId = p.SelectedCat;
                    np.Location = p.SelectedPos;
                    np.Description = p.Description;
                    np.Price = decimal.Parse(p.ProductPrice);
                    np.UserId = u.Id;
                    np.ProductKey = p.ProductKey;

                    WebApiHelper.AddProductToServer("api/product/add", Method.PUT, np);

                    return RedirectToAction("UploadPicture", "ProductManager", p);
                }
                else
                {
                    FormsAuthentication.SignOut();
                    Session["role"] = null;
                    Session["UserId"] = null;
                    return RedirectToAction("Logout", "Account");
                }
                           
            }

            return View(p);
        }
        public ActionResult EditProduct(ProductUploadViewModel p)
        {
            if (ModelState.IsValid)
            {
                ProductApi np = new ProductApi();
                np.Id = p.Id;
                np.Name = p.ProductName;
                np.CategoryId = p.SelectedCat;
                np.Location = p.SelectedPos;
                np.Description = p.Description;
                np.Price = decimal.Parse(p.ProductPrice);
                np.UserId = (int) Session["UserId"];
                np.ProductKey = p.ProductKey;

                WebApiHelper.EditProductOnServer("api/product/edit", Method.POST, np);

                return RedirectToAction("EditSuccessful", "ProductManager", p);
            }

            return View(p);
        }
 public ActionResult EditSuccessful(ProductUploadViewModel p)
 {
     return View();
 }
        public ActionResult EditProduct()
        {
            int id = int.Parse(Request.QueryString["proId"]);
            var ps = WebApiHelper.GetProductsFromServer("api/product/all", Method.GET);
            DataTransferLayer.Products.Product p = ps.FirstOrDefault(pr => pr.Id == id);
            

            ProductUploadViewModel pro = new ProductUploadViewModel();
            if (p != null)
            {
                pro.Id = p.Id;
                pro.ProductName = p.Name;
                pro.Description = p.Description;
                pro.SelectedCat = p.CategoryId;
                pro.ProductPrice = p.Price.ToString(CultureInfo.InvariantCulture);
                pro.SelectedPos = p.Location;
                pro.ProductKey = p.ProductKey;
            }

            return View(pro);
        }