예제 #1
0
        private CategoryEditCreateModel PrepareCategoryEditCreateModel(Category category)
        {
            var model = new CategoryEditCreateModel();

            model.Description      = category.Description;
            model.Name             = category.Name;
            model.Id               = category.Id;
            model.ParentCategoryId = category.ParentCategoryId;
            model.ShortDescription = category.ShortDescription;
            model.PhotoURL         = _photoService.GetPhotoById(category.PhotoId ?? 0).FileUrl;
            model.ShowOnHomePage   = category.ShowHomePage;
            model.Queue            = category.Queue;
            return(model);
        }
예제 #2
0
 public ActionResult CreateCategory(CategoryEditCreateModel model)
 {
     if (ModelState.IsValid)
     {
         _categoryService.CreateCategory(new Category
         {
             UserId           = UserId,
             Description      = model.Description,
             Name             = model.Name,
             ShortDescription = model.ShortDescription,
             ShowHomePage     = model.ShowOnHomePage,
             Queue            = model.Queue,
             ParentCategoryId = model.ParentCategoryId,
             CreateDate       = DateTime.Now,
             Slug             = Server.MapPath("~/uploads")
         }, model.Photo);
         return(RedirectToAction("Index"));
     }
     ViewBag.ParentCategoryId = new SelectList(_categoryService.GetAllCategories(), "Id", "Name", model.ParentCategoryId);
     return(View(model));
 }