public async Task <IActionResult> PutTcategory(short id, Tcategory tcategory) { if (id != tcategory.TcategoryId) { return(BadRequest()); } _context.Entry(tcategory).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TcategoryExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Delete(int?id) { Tcategory tcategory = db.Tcategory.Where(x => x.category_id == id).SingleOrDefault(); db.Tcategory.Remove(tcategory); db.SaveChanges(); return(RedirectToAction("ViewCategory")); }
public ActionResult ProductDetails(int?id) { ProductDetails productDetails = new ProductDetails(); Tproduct product = db.Tproduct.Where(x => x.product_id == id).SingleOrDefault(); productDetails.product_id = product.product_id; productDetails.product_name = product.product_name; productDetails.product_image = product.product_image; productDetails.product_price = product.product_price; Tcategory category = db.Tcategory.Where(x => x.category_id == product.product_fk_category).SingleOrDefault(); productDetails.category_name = category.category_name; Tuser user = db.Tuser.Where(x => x.Tuser_id == product.product_fk_user).SingleOrDefault(); productDetails.Tuser_name = user.Tuser_name; productDetails.Tuser_image = user.Tuser_image; productDetails.Tuser_contact = user.Tuser_contact; productDetails.product_fk_user = user.Tuser_id; return(View(productDetails)); }
public ActionResult Create(Tcategory cvm, HttpPostedFileBase imgfile) { string path = uploadimgfile(imgfile); if (path.Equals("-1")) { ViewBag.error = "Image couldnt upload"; } else { Tcategory category = new Tcategory(); category.category_name = cvm.category_name; category.category_image = path; category.category_status = 1; category.category_fk_admin = Convert.ToInt32(Session["admin_id"].ToString()); db.Tcategory.Add(category); db.SaveChanges(); return(RedirectToAction("ViewCategory")); } return(View()); }
public async Task <ActionResult <Tcategory> > PostTcategory(Tcategory tcategory) { _context.Tcategory.Add(tcategory); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TcategoryExists(tcategory.TcategoryId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetTcategory", new { id = tcategory.TcategoryId }, tcategory)); }