public ActionResult Edit(int id, tbl_Item obj, HttpPostedFileBase image) { try { string imgpath = string.Empty; if (image != null) { string filename = Path.GetFileName(image.FileName); imgpath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image.FileName)); image.SaveAs(imgpath); imgpath = filename; } obj.itemimage = imgpath; ViewBag.FileStatus = "YES"; db.Sp_Item_update(obj.ItemID, obj.BrandID, obj.ItemName, obj.itemimage); // TODO: Add update logic here return(RedirectToAction("List")); } catch { return(View()); } }
public IHttpActionResult Posttbl_Item(tbl_Item tbl_Item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tbl_Item.Add(tbl_Item); try { db.SaveChanges(); } catch (DbUpdateException) { if (tbl_ItemExists(tbl_Item.ItemId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = tbl_Item.ItemId }, tbl_Item)); }
public IHttpActionResult Puttbl_Item([FromUri] int id, tbl_Item tbl_Item) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tbl_Item.ItemId) { return(NotFound()); } db.Entry(tbl_Item).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tbl_ItemExists(id)) { return(NotFound()); } else { throw; } } return(Ok(tbl_Item)); }
public IHttpActionResult Deletetbl_Item(int id) { tbl_Item tbl_Item = db.tbl_Item.Find(id); if (tbl_Item == null) { return(NotFound()); } db.tbl_Item.Remove(tbl_Item); db.SaveChanges(); return(Ok(tbl_Item)); }
public IHttpActionResult Gettbl_Item(int id) { tbl_Item tbl_Item = db.tbl_Item.Include(b => b.tbl_User) .Include(b => b.tbl_Shipping) .Include(b => b.tbl_ItemDetail) .Include(b => b.tbl_Category) .FirstOrDefault(b => b.ItemId == id); if (tbl_Item == null) { return(NotFound()); } return(Ok(tbl_Item)); }
public ActionResult Create(tbl_Item obj, HttpPostedFileBase image) { try { string imgpath = string.Empty; if (image != null) { string filename = Path.GetFileName(image.FileName); imgpath = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(image.FileName)); image.SaveAs(imgpath); imgpath = filename; } obj.itemimage = imgpath; db.Sp_Item_insert(obj.BrandID, obj.ItemName, obj.itemimage); return(RedirectToAction("List")); } catch { return(View()); } }