public void UpdateProd(ProductsViewModel prodviewmodel) { try { tbl_Products tblprod = new tbl_Products(); tblprod.ProductID = prodviewmodel.ProductID; tblprod.ReqReference = prodviewmodel.ReqReference; tblprod.daid = prodviewmodel.daid; tblprod.BuzProdID = prodviewmodel.BuzProdID; tblprod.LobID = prodviewmodel.LobID; tblprod.EntityState = DA.DomainModel.EntityState.Modified; ProductsManager prodManager = new ProductsManager(); prodManager.UpdateProduct(tblprod); } catch (Exception) { throw; } }
public IHttpActionResult PutProduct(tbl_Products obj) { var data = dbobj.tbl_Products.Where(x => x.Id == obj.Id).First <tbl_Products>(); if (data != null) { data.Name = obj.Name; data.Category = obj.Category; data.Price = obj.Price; data.Quantity = obj.Quantity; data.ShortDescription = obj.ShortDescription; data.LongDescription = obj.LongDescription; data.SmallImage = obj.SmallImage; data.LargeImage = obj.LargeImage; dbobj.SaveChanges(); return(Ok()); } else { return(NotFound()); } }
public ProductModal SaveProduct(ProductModal _objdata) { tbl_Products _objproduct = new tbl_Products(); try { using (newconecommerce dataContext = new newconecommerce()) { dataContext.Database.Connection.Open(); _objproduct.v_name = _objdata.strProductName; _objproduct.fl_price = Convert.ToDouble(_objdata.dblPrice); _objproduct.int_quantity = _objdata.intQuantity; _objproduct.fl_weight = Convert.ToDouble(_objdata.dblWeight); _objproduct.fl_length = Convert.ToDouble(_objdata.flLength); _objproduct.fl_breadth = Convert.ToDouble(_objdata.flBreadth); _objproduct.fl_height = Convert.ToDouble(_objdata.flHeight); _objproduct.fl_GST = Convert.ToDouble(_objdata.flGST); _objproduct.fl_QtyDiscount = _objdata.dblQtyDiscount; _objproduct.int_BrandsId = _objdata.intBrands; _objproduct.int_CategoryId = _objdata.intCategory; _objproduct.v_image = _objdata.strImagePath; _objproduct.v_description_info = _objdata.strDescription; _objproduct.dt_created_on = DateTime.Now; _objproduct.b_IsActive = true; dataContext.tbl_Products.Add(_objproduct); dataContext.SaveChanges(); dataContext.Database.Connection.Close(); _objdata.StatusMessaage = "Product save sucessfully."; return(_objdata); } } catch (Exception) { throw; } }
public IHttpActionResult AddProduct(tbl_Products data) { dbobj.tbl_Products.Add(data); dbobj.SaveChanges(); return(Ok()); }
public ActionResult EditProduct(HttpPostedFileBase smallimage, HttpPostedFileBase largeimage, tbl_Products data1) { String smallfile = Path.GetFileName(smallimage.FileName); String smallfile1 = DateTime.Now.ToString("yymmssfff") + smallfile; string smallextension = Path.GetExtension(smallimage.FileName); String smallpath = Path.Combine(Server.MapPath("/Product_Image/Small_Image/"), smallfile1); data1.SmallImage = "/Product_Image/Small_Image/" + smallfile1; String largefile = Path.GetFileName(largeimage.FileName); String largefile1 = DateTime.Now.ToString("yymmssfff") + largefile; string largeextension = Path.GetExtension(largeimage.FileName); String largepath = Path.Combine(Server.MapPath("/Product_Image/Large_Image/"), largefile1); data1.LargeImage = "/Product_Image/Large_Image/" + largefile1; if (smallextension.ToLower() == ".jpg" || smallextension.ToLower() == ".jpeg" || smallextension.ToLower() == ".png" || largeextension.ToLower() == ".jpg" || largeextension.ToLower() == ".jpeg" || largeextension.ToLower() == ".png") { if (smallimage.ContentLength <= 10000000 || largeimage.ContentLength <= 10000000) { smallimage.SaveAs(smallpath); largeimage.SaveAs(largepath); HttpClient hc = new HttpClient(); hc.BaseAddress = new Uri("https://localhost:44393/api/Product/"); var registerdata = hc.PutAsJsonAsync <tbl_Products>("PutProduct", data1); registerdata.Wait(); var savedata = registerdata.Result; if (savedata.IsSuccessStatusCode) { return(RedirectToAction("Dashboard")); } } } return(View()); }