public ActionResult Create(BusinessZoneVM businessZone) { if (ModelState.IsValid) { tbld_business_zone bZvm = new tbld_business_zone { id = businessZone.Id, biz_zone_name = businessZone.BizZoneName, biz_zone_code = businessZone.BizZoneCode, biz_zone_description = businessZone.BizZoneDescription, biz_zone_category_id = businessZone.BizZoneCategoryId, parent_biz_zone_id = businessZone.ParentBizZoneId }; Db.tbld_business_zone.Add(bZvm); Db.SaveChanges(); TempData["alertbox"] = "success"; TempData["alertboxMsg"] = bZvm.biz_zone_name + "Zone Create Successfully"; return(RedirectToAction("Index")); } businessZone.BizZoneCategoryId = 0; return(View(businessZone)); }
public ActionResult Edit(BusinessZoneVM businessZone) { if (businessZone.BizZoneCategoryId == 1) { businessZone.ParentBizZoneId = 0; } if (ModelState.IsValid) { tbld_business_zone bZvm = new tbld_business_zone(); bZvm.id = businessZone.Id; bZvm.biz_zone_name = businessZone.BizZoneName; bZvm.biz_zone_code = businessZone.BizZoneCode; bZvm.biz_zone_description = businessZone.BizZoneDescription; bZvm.biz_zone_category_id = businessZone.BizZoneCategoryId; bZvm.parent_biz_zone_id = businessZone.ParentBizZoneId; Db.Entry(bZvm).State = EntityState.Modified; Db.SaveChanges(); TempData["alertbox"] = "success"; TempData["alertboxMsg"] = bZvm.biz_zone_name + " Zone Edit Successfully"; return(RedirectToAction("Index")); } return(View(businessZone)); }
public ActionResult DeleteConfirmed(int id) { tbld_business_zone tbldBusinessZone = Db.tbld_business_zone.Find(id); if (tbldBusinessZone != null) { Db.tbld_business_zone.Remove(tbldBusinessZone); Db.SaveChanges(); TempData["alertbox"] = "success"; TempData["alertboxMsg"] = tbldBusinessZone.biz_zone_name + " Zone Delete Successfully"; } return(RedirectToAction("Index")); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tbld_business_zone tbldBusinessZone = Db.tbld_business_zone.Find(id); if (tbldBusinessZone == null) { return(HttpNotFound()); } ViewBag.ZoneCatagory = Db.tbld_business_zone_hierarchy.ToList(); ViewBag.ZoneParent = Db.tbld_business_zone.Where(x => x.biz_zone_category_id == tbldBusinessZone.biz_zone_category_id - 1).ToList(); return(View(tbldBusinessZone)); }