public long AddProductCategory(product_category product_category) { try { product_category insert_product_category = new product_category { product_category_name = product_category.product_category_name, product_category_code = product_category.product_category_code, //created_by = created_date = DateTime.Now, //updated_by = updated_date = DateTime.Now, is_active = true, is_deleted = false, }; _entities.product_category.Add(insert_product_category); _entities.SaveChanges(); long last_insert_id = insert_product_category.product_category_id; return(last_insert_id); } catch (Exception ex) { return(0); } }
/// <summary> /// Save Category details in database /// </summary> /// <param name="categoryDetails">Category details to be saved</param> /// <returns>returns boolean value indicating if the records are saved in database</returns> bool ICategoryService.SaveCategoryDetails(ProductCategoryDTO categoryDetails) { product_category categoryEntity = new product_category(); ObjectMapper.Map(categoryDetails, categoryEntity); return(CategoryRepository.Save(categoryEntity)); }
public ActionResult DeleteConfirmed(int id) { product_category product_category = db.product_category.Find(id); db.product_category.Remove(product_category); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "category_id,name")] product_category product_category) { if (ModelState.IsValid) { db.Entry(product_category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product_category)); }
public ActionResult Create([Bind(Include = "category_id,name")] product_category product_category) { if (ModelState.IsValid) { db.category.Add(product_category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product_category)); }
public ActionResult Edit([Bind(Include = "id,product_id,category_id")] product_category product_category) { if (ModelState.IsValid) { db.Entry(product_category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.category_id = new SelectList(db.categories, "id", "name", product_category.category_id); ViewBag.product_id = new SelectList(db.products, "id", "name", product_category.product_id); return(View(product_category)); }
// GET: product_category/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } product_category product_category = db.product_category.Find(id); if (product_category == null) { return(HttpNotFound()); } return(View(product_category)); }
public bool DeleteProductCategory(long product_category_id) { try { product_category oProductCategory = _entities.product_category.FirstOrDefault(c => c.product_category_id == product_category_id); oProductCategory.is_active = false; oProductCategory.is_deleted = true; _entities.SaveChanges(); return(true); } catch (Exception) { return(false); } }
// GET: product_category/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } product_category product_category = db.product_category.Find(id); if (product_category == null) { return(HttpNotFound()); } ViewBag.category_id = new SelectList(db.categories, "id", "name", product_category.category_id); ViewBag.product_id = new SelectList(db.products, "id", "name", product_category.product_id); return(View(product_category)); }
public bool EditProductCategory(product_category product_category) { try { product_category oProductCategory = _entities.product_category.Find(product_category.product_category_id); oProductCategory.product_category_name = product_category.product_category_name; oProductCategory.product_category_code = product_category.product_category_code; //updated_by = oProductCategory.updated_date = DateTime.Now; _entities.SaveChanges(); return(true); } catch (Exception ex) { return(false); } }
public HttpResponseMessage Post([FromBody] Models.product_category product_category) { try { if (string.IsNullOrEmpty(product_category.product_category_name)) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Name is Empty" }, formatter)); } else { product_category insert_product_category = new product_category { product_category_name = product_category.product_category_name, product_category_code = product_category.product_category_code }; productCategoryRepository.AddProductCategory(insert_product_category); var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "success", msg = "Product Category save successfully" }, formatter)); } } catch (Exception ex) { var formatter = RequestFormat.JsonFormaterString(); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = ex.ToString() }, formatter)); } }