Пример #1
0
 public ActionResult Index()
 {
     var categories = _categoryRepository.GetAllCategories();
     var sm = new SearchModel
                  {
                      Categories = new List<CategoryModel>()
                  };
     foreach (var category in categories)
     {
         var c = new CategoryModel
                     {
                         CategoryName = category.CategoryName,
                         Skills = new List<SkillModel>()
                     };
         foreach (var skill in category.Skills)
         {
             c.Skills.Add(new SkillModel
                              {
                                  SkillId = skill.SkillID,
                                  SkillName = skill.SkillName
                              });
         }
         sm.Categories.Add(c);
     }
     return View(sm);
 }
Пример #2
0
 public ActionResult Create(CategoryModel categorymodel)
 {
     try
     {
         var category = new Category();
         if (categorymodel != null)
         {
             category.CategoryName = categorymodel.CategoryName;
         }
         _categoryRepository.InsertCategory(category);
         _categoryRepository.Save();
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Пример #3
0
        public ActionResult Delete(int id)
        {
            var categoryDetails = _categoryRepository.GetCategoryById(id);
            var category = new CategoryModel();

            if (categoryDetails != null)
            {
                category.CategoryName = categoryDetails.CategoryName;
            }
            return View(category);
        }
Пример #4
0
 public ActionResult Index()
 {
     IEnumerable<Category> categoryList = _categoryRepository.GetAllCategories().ToList();
     var categories = new List<CategoryModel>();
     if (categoryList.Any())
     {
         foreach (var category in categoryList)
         {
             var c = new CategoryModel
                         {
                             CategoryId = category.CategoryId,
                             CategoryName = category.CategoryName,
                             Skills = new List<SkillModel>()
                         };
             foreach (Skill skill in category.Skills)
             {
                 c.Skills.Add(new SkillModel
                                  {
                                      SkillId = skill.SkillID,
                                      SkillName = skill.SkillName
                                  });
             }
             categories.Add(c);
         }
     }
     return View(categories);
 }
Пример #5
0
 public ActionResult Edit(int id)
 {
     var categoryDetails = _categoryRepository.GetCategoryById(id);
     var category = new CategoryModel();
     if (categoryDetails != null)
     {
         category.CategoryName = categoryDetails.CategoryName;
         return View(category);
     }
     return RedirectToAction("Index");
 }