Ejemplo n.º 1
0
 public Category CategoryListingToModel(CategoryListingModel model)
 {
     return(new Category
     {
         Id = model.Id,
         Name = model.Name,
         Description = model.Description,
         ImageUrl = model.ImageUrl,
     });
 }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
0
        // 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));
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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));
        }