// GET: SubCategory/Create public ActionResult Create() { SubCategoryModel SubCategoryModel = new CommunicationApp.Models.SubCategoryModel(); ViewBag.CategoryId = new SelectList(_CategoryService.Categories(), "CategoryId", "CategoryName"); return(View(SubCategoryModel)); }
// GET: SubCategory/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubCategory subCategory = _SubCategoryService.GetSubCategory(Convert.ToInt32(id)); Mapper.CreateMap <CommunicationApp.Entity.SubCategory, CommunicationApp.Models.SubCategoryModel>(); CommunicationApp.Models.SubCategoryModel SubCategoryModel = Mapper.Map <CommunicationApp.Entity.SubCategory, CommunicationApp.Models.SubCategoryModel>(subCategory); if (subCategory == null) { return(HttpNotFound()); } ViewBag.CategoryIdList = new SelectList(_CategoryService.Categories(), "CategoryId", "CategoryName", subCategory.CategoryId); return(View(SubCategoryModel)); }