public ActionResult SearchByName(mvcProductModel prod) { HttpResponseMessage response = GlobalHttp.WebApiClient.GetAsync("Products/Search/" + prod.ProdName).Result; mvcProductModel product = response.Content.ReadAsAsync <mvcProductModel>().Result; TempData["SuccessMessage"] = product.ProdId + " is Id"; return(RedirectToAction("Index")); }
public ActionResult UpdateQuantity(int id, int reducequantity) { HttpResponseMessage response = GlobalHttp.WebApiClient.GetAsync("Products/" + id.ToString()).Result; mvcProductModel product = response.Content.ReadAsAsync <mvcProductModel>().Result; product.ProdQuantity -= reducequantity; HttpResponseMessage response2 = GlobalHttp.WebApiClient.PutAsJsonAsync("Products/" + id.ToString(), product).Result; return(RedirectToAction("Index")); }
public ActionResult AttributeList(int id) { mvcProductModel product = new mvcProductModel(); List <mvcAttributeModel> attributeList; HttpResponseMessage responceA = GlobaleVariables.webApiClient.GetAsync("Products/GetAttributeLookups/" + id).Result; attributeList = responceA.Content.ReadAsAsync <List <mvcAttributeModel> >().Result; product.AttributeList = attributeList; return(PartialView("_AttributeList", product)); }
public ActionResult AddOrEdit(int id = 0) { if (id == 0) { return(View(new mvcProductModel())); } else { HttpResponseMessage response = GlobalHttp.WebApiClient.GetAsync("Products/" + id.ToString()).Result; mvcProductModel product = response.Content.ReadAsAsync <mvcProductModel>().Result; return(View(product)); } }
public ActionResult AddOrEdit(mvcProductModel productModel) { if (productModel.Id == 0) { HttpResponseMessage response = GlobalVariable.WebApiClient.PostAsJsonAsync("Product", productModel).Result; TempData["SuccessMessage"] = "Saved Successfully"; } else { HttpResponseMessage response = GlobalVariable.WebApiClient.PutAsJsonAsync("Product/" + productModel.Id, productModel).Result; TempData["SuccessMessage"] = "Updated Successfully"; } return(RedirectToAction("Index")); }
public ActionResult AddOrEdit(mvcProductModel product) { if (product.ProdId == 0) { HttpResponseMessage request = GlobalHttp.WebApiClient.PostAsJsonAsync("Products", product).Result; TempData["SuccessMessage"] = product.ProdName + " Record Added Succfully!!"; } else { HttpResponseMessage response = GlobalHttp.WebApiClient.PutAsJsonAsync("Products/" + product.ProdId, product).Result; TempData["SuccessMessage"] = product.ProdName + " Record Updated Succfully!!"; } return(Redirect("Index")); }
public ActionResult AddOrEditProduct(mvcProductModel product) { if (product.ProductId == 0) { HttpResponseMessage responce = GlobaleVariables.webApiClient.PostAsJsonAsync("Products", product).Result; TempData["successMessage"] = "Create Successfully"; return(RedirectToAction("ProductList")); } else { HttpResponseMessage responce = GlobaleVariables.webApiClient.PutAsJsonAsync("Products/" + product.ProductId, product).Result; TempData["successMessage"] = "Update Successfully"; return(RedirectToAction("ProductList")); } }
public ActionResult Add(int total, int prodId, int quantity, int imageId) { HttpResponseMessage prodresponse = GlobalHttp.WebApiClient.GetAsync("Products/" + prodId.ToString()).Result; mvcProductModel product = prodresponse.Content.ReadAsAsync <mvcProductModel> ().Result; mvcCartModel cart = new mvcCartModel(); cart.CartDetailId = 1; cart.CartQuantity = quantity; cart.CartTotal = total; cart.ProductID = prodId; cart.ImageId = imageId; cart.ProductName = product.ProdName; HttpResponseMessage response = GlobalHttp.WebApiClient.PostAsJsonAsync("Carts", cart).Result; TempData["SuccessMessage"] = "Item Added in to Cart"; return(RedirectToAction("Index", "Product")); }
public ActionResult Update(int prodId, int newQuantity, int oldQuantity, int cartId, int imageId) { HttpResponseMessage prodresponse = GlobalHttp.WebApiClient.GetAsync("Products/" + prodId.ToString()).Result; mvcProductModel product = prodresponse.Content.ReadAsAsync <mvcProductModel>().Result; int actualQuantity = 0; if (newQuantity > oldQuantity) { actualQuantity = newQuantity - oldQuantity; product.ProdQuantity -= actualQuantity; } else { actualQuantity = oldQuantity - newQuantity; product.ProdQuantity += actualQuantity; } if (product.ProdQuantity < actualQuantity) { TempData["AlertMessage"] = "Only " + product.ProdQuantity + " are Available!!"; return(RedirectToAction("Index")); } else { //CArt HttpResponseMessage cartresponse = GlobalHttp.WebApiClient.GetAsync("Carts/" + cartId.ToString()).Result; mvcCartModel cart = cartresponse.Content.ReadAsAsync <mvcCartModel>().Result; cart.CartQuantity = newQuantity; cart.CartTotal = newQuantity * product.ProdPrice; cart.ImageId = imageId; HttpResponseMessage response = GlobalHttp.WebApiClient.PutAsJsonAsync("Carts/" + cart.CartId.ToString(), cart).Result; //Product HttpResponseMessage productresponse = GlobalHttp.WebApiClient.PutAsJsonAsync("Products/" + product.ProdId.ToString(), product).Result; TempData["SuccessMessage"] = "Item Updated Successfully!!"; return(RedirectToAction("Index")); } }
public ActionResult AddOrEdit(mvcProductModel product, Image file) { //int shopId = shop.GetShop(); //product.ShopId = shopId; if (file.ImageFile != null) { string fileName = Path.GetFileNameWithoutExtension(file.ImageFile.FileName); string extension = Path.GetExtension(file.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("tijarat") + extension; file.ImagePath = "/Images/Product/" + fileName; fileName = Path.Combine(Server.MapPath("~/Images/Product/"), fileName); file.ImageFile.SaveAs(fileName); using (Smart_POS2Image db = new Smart_POS2Image()) { db.Images.Add(file); db.SaveChanges(); product.ImageID = db.Images.Max(image => image.ImageID); } ModelState.Clear(); } else { TempData["AlertMessage"] = "Image Path is Null "; } if (product.ProdId == 0) { HttpResponseMessage request = GlobalHttp.WebApiClient.PostAsJsonAsync("Products", product).Result; TempData["SuccessMessage"] = product.ProdName + " Record Added Succfully!!"; } else { HttpResponseMessage response = GlobalHttp.WebApiClient.PutAsJsonAsync("Products/" + product.ProdId, product).Result; TempData["SuccessMessage"] = product.ProdName + " Record Updated Succfully!!"; } return(RedirectToAction("Index")); }
public ActionResult AddOrEditProduct(int id = 0) { mvcProductModel product = new mvcProductModel(); List <mvcCategoryModel> categoryList; List <mvcAttributeModel> attributeList; if (id == 0) { HttpResponseMessage responce = GlobaleVariables.webApiClient.GetAsync("Products/GetCategory").Result; categoryList = responce.Content.ReadAsAsync <List <mvcCategoryModel> >().Result; product.CategoryList = categoryList; HttpResponseMessage responceA = GlobaleVariables.webApiClient.GetAsync("Products/GetAttributeLookups/" + categoryList.First().ProdCatId).Result; attributeList = responceA.Content.ReadAsAsync <List <mvcAttributeModel> >().Result; product.AttributeList = attributeList; } else { HttpResponseMessage responce = GlobaleVariables.webApiClient.GetAsync("Products/" + id).Result; product = responce.Content.ReadAsAsync <mvcProductModel>().Result; } return(View(product)); }
public ActionResult AddOrEdit(mvcProductModel prod) { HttpResponseMessage respuesta = VariablesGlobales.webClient.PostAsJsonAsync("productoes", prod).Result; return(RedirectToAction("Index")); }
public ActionResult Add(mvcProductModel prod) { HttpResponseMessage response = GlobalVariables.WebApiClient.PostAsJsonAsync("Product", prod).Result; return(RedirectToAction("Add")); }