public Category CategoryListingToModel(CategoryListingModel model) { return(new Category { Id = model.Id, Name = model.Name, Description = model.Description, ImageUrl = model.ImageUrl, }); }
public async Task <IActionResult> Edit(CategoryListingModel model) { if (!ModelState.IsValid) { return(View(model)); } await this.categories.EditAsync(model.Id, model.Name); return(RedirectToAction(nameof(Index))); }
// GET: Dashboard/Categories public ActionResult Index(string searchTerm, int?categoryID, int?pageNo) { CategoryListingModel model = new CategoryListingModel(); int recordSize = 9; pageNo = pageNo ?? 1; model.SearchTerm = searchTerm; model.Categories = CategoryService.Instance.SearchCategories(searchTerm, pageNo.Value, recordSize); var totalRecord = CategoryService.Instance.SearchCategoriesCount(searchTerm); model.Pager = new Pager(totalRecord, pageNo, recordSize); return(View(model)); }
public IActionResult New(CategoryListingModel model) { if (ModelState.IsValid) { var category = _mapper.CategoryListingToModel(model); _categoryService.NewCategory(category); return(RedirectToAction("Topic", new { id = category.Id, searchQuery = "" })); } ViewBag.ActionText = "create"; ViewBag.Action = "New"; ViewBag.CancelAction = "Index"; ViewBag.SubmitText = "Create Category"; return(View("CreateEdit", model)); }
public IActionResult Edit(CategoryListingModel model) { if (ModelState.IsValid) { var category = _mapper.CategoryListingToModel(model); _categoryService.EditCategory(category); return(RedirectToAction("Topic", new { id = category.Id, searchQuery = "" })); } ViewBag.ActionText = "change"; ViewBag.Action = "Edit"; ViewBag.CancelAction = "Topic"; ViewBag.SubmitText = "Save Changes"; ViewBag.RouteId = model.Id; return(View("CreateEdit", model)); }