public IHttpActionResult PuttblProductCategory(int id, tblProductCategory tblProductCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblProductCategory.recNo) { return(BadRequest()); } db.Entry(tblProductCategory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblProductCategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GettblProductCategory(int id) { tblProductCategory tblProductCategory = db.tblProductCategories.Find(id); if (tblProductCategory == null) { return(NotFound()); } return(Ok(tblProductCategory)); }
public IHttpActionResult DeletetblProductCategory(int id) { tblProductCategory tblProductCategory = db.tblProductCategories.Find(id); if (tblProductCategory == null) { return(NotFound()); } db.tblProductCategories.Remove(tblProductCategory); db.SaveChanges(); return(Ok(tblProductCategory)); }
public bool UpdateCategory(console.Models.tblProductCategory entity) { bool result = false; using (var context = new console.Models.dream_techContext()) { tblProductCategory cat = (from c in context.tblProductCategories where c.category_id == entity.category_id select c).First(); cat.product_category = entity.product_category; result = context.SaveChanges() > 1; } return(result); }
public IHttpActionResult PosttblProductCategory(tblProductCategory tblProductCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } tblProductCategory.CategoryId = Guid.NewGuid().ToString("N").Substring(0, 4).ToUpper(); tblProductCategory.CategoryName = tblProductCategory.CategoryName.ToUpper(); db.tblProductCategories.Add(tblProductCategory); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tblProductCategory.recNo }, tblProductCategory)); }
// GET: ProductCategories/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblProductCategory tblProductCategory = db.tblProductCategories.Find(id); if (tblProductCategory == null) { return(HttpNotFound()); } ViewBag.ProductCategory = tblProductCategory; var tblProductCategories = db.tblProductCategories.ToList().Where(a => a.IsActive == true).ToList(); return(View("Index", tblProductCategories.ToList())); }
public ActionResult Edit([Bind(Include = "ProductCategoryID,CategoryName,Description,HSN_SAC,CreatedOn,UpdatedOn,CreatedBy,UpdatedBy,IsActive")] tblProductCategory tblProductCategory) { if (ModelState.IsValid) { tblUser objSource = (tblUser)Session["UserDetails"]; tblProductCategory.UpdatedBy = objSource.Id; tblProductCategory.UpdatedOn = DateTime.Now; db.Entry(tblProductCategory).State = EntityState.Modified; ViewBag.ProductCategory = new tblProductCategory(); TempData["Success"] = "Product Category updated successfully."; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductCategory = new tblProductCategory(); var tblProductCategories = db.tblProductCategories.ToList().Where(a => a.IsActive == true).ToList(); return(View("Index", tblProductCategories.ToList())); }
// GET: ProductCategories/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblUser objSource = (tblUser)Session["UserDetails"]; tblProductCategory tblProductCategory = db.tblProductCategories.Find(id); if (tblProductCategory == null) { return(HttpNotFound()); } else { tblProductCategory.IsActive = false; tblProductCategory.UpdatedBy = objSource.Id; tblProductCategory.UpdatedOn = DateTime.Now; db.Entry(tblProductCategory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } }