public IHttpActionResult PutProductTable(int id, ProductTable productTable) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != productTable.Id) { return(BadRequest()); } db.Entry(productTable).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ProductTableExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Create([Bind(Include = "ProductId,ProductName,Price,Brand,Type,Details,ImageData")] ProductTable producttable) { if (ModelState.IsValid) { db.ProductTables.Add(producttable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(producttable)); }
public ActionResult Create([Bind(Include = "Id,Name,Category,Price,Quantity,Short_Description,Long_Description,Small_image,Large_image")] ProductListData productListData) { if (ModelState.IsValid) { db.ProductListDatas.Add(productListData); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productListData)); }
public ActionResult Create([Bind(Include = "Id,UrlTitle,Title,Categories,Tags,Html,IsTagged")] ProductTable productTable) { GetListofCategories(); if (ModelState.IsValid) { db.ProductTables.Add(productTable); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(productTable)); }
public ActionResult Addimg(ProductListData p) { string filename = Path.GetFileNameWithoutExtension(p.ImageFile.FileName); string filename1 = Path.GetFileNameWithoutExtension(p.Large_ImageFile.FileName); string extension = Path.GetExtension(p.ImageFile.FileName); string extension1 = Path.GetExtension(p.Large_ImageFile.FileName); filename = filename + DateTime.Now.ToString("yymmssfff") + extension; filename1 = filename1 + DateTime.Now.ToString("yymmssfff") + extension1; p.Small_image = "~/SmallImg/" + filename; p.Large_image = "~/LargeImg/" + filename1; filename = Path.Combine(Server.MapPath("~/SmallImg"), filename); filename1 = Path.Combine(Server.MapPath("~/LargeImg"), filename1); p.ImageFile.SaveAs(filename); p.Large_ImageFile.SaveAs(filename1); db.ProductListDatas.Add(p); db.SaveChanges(); ModelState.Clear(); return(View()); }
public ActionResult AddProduct(ProductTable PD) { ProductDatabaseEntities db = new ProductDatabaseEntities(); ProductTable pt = new ProductTable(); pt.ProductName = PD.ProductName; pt.Price = PD.Price; pt.Brand = PD.Brand; pt.Type = PD.Type; pt.Details = PD.Details; //pt.ImageData = PD.ImageData; //byte[] data = new byte[pt.File.ContentLength]; byte[] data = new byte[PD.File.ContentLength]; PD.File.InputStream.Read(data, 0, PD.File.ContentLength); pt.ImageData = data; using (ProductDatabaseEntities dc = new ProductDatabaseEntities()) { dc.ProductTables.Add(pt); dc.SaveChanges(); @ViewBag.Success = "Seccessfully Added!"; } return(RedirectToAction("AddProduct")); }
public ActionResult Signup(user model) { using (var context = new ProductDatabaseEntities()) { context.users.Add(model); context.SaveChanges(); } return(RedirectToAction("login")); }