Exemple #1
0
 public ActionResult Add(SkillCatalogModel skillCatalogModel)
 {
     if (ModelState.IsValid && skillCatalogModel.SelectedSkill != null && skillCatalogModel.SelectedMark != null)
     {
         if (WebSecurity.IsAuthenticated)
         {
             var userID = WebSecurity.CurrentUserId;
             UserSkill existedUserSkill = _skillRepository.GetUserSkill((int) skillCatalogModel.SelectedSkill, userID);
             if (existedUserSkill != null)
             {
                 if (existedUserSkill.Mark != skillCatalogModel.SelectedMark)
                 {
                     var submittingUserSkill = new SubmittingUserSkill
                                 {
                                     SkillName = existedUserSkill.Skill.SkillName,
                                     ExistedMark = existedUserSkill.Mark,
                                     NewMark = (int) skillCatalogModel.SelectedMark,
                                     SkillId = (int) skillCatalogModel.SelectedSkill
                                 };
                     return View("SubmitReplase", submittingUserSkill);
                 }
                 TempData["Message"] = string.Format("Skill {0} with mark {1} already exists. Want to add another?",
                                               existedUserSkill.Skill.SkillName, existedUserSkill.Mark);
                 return RedirectToAction("Add");
             }
             _skillRepository.AddUserSkill((int) skillCatalogModel.SelectedSkill, userID, (int) skillCatalogModel.SelectedMark);
             //todo: send update msg
             sendUpdateMsg();
         }
     }
     return RedirectToAction("Index");
 }
Exemple #2
0
 public ActionResult Add()
 {
     var skillCatalogModel = new SkillCatalogModel();
     var categoriesList = _categoryRepository.GetAllCategories();
     var categories = new List<CategoryModel>();
     foreach (var category in categoriesList)
     {
         categories.Add(new CategoryModel
                            {
                                CategoryId = category.CategoryId,
                                CategoryName = category.CategoryName
                            });
     }
     skillCatalogModel.Categories = categories;
     ViewBag.Title = TempData["Message"] ?? "Adding new skill";
     return View(skillCatalogModel);
 }
Exemple #3
0
 public ActionResult SelectCategory(int? selectedCategory)
 {
     var skillCatalogModel = new SkillCatalogModel
                                 {
                                     Skills = new List<SkillModel>()
                                 };
     var skillModels = new List<SkillModel>();
     var skills = new List<Skill>();
     if (selectedCategory.HasValue)
     {
         skills = _skillRepository.GetSkillsByCategoryId((int) selectedCategory);
     }
     foreach (var s in skills)
     {
         skillModels.Add(new SkillModel
                             {
                                 SkillId = s.SkillID,
                                 SkillName = s.SkillName
                             });
     }
     skillCatalogModel.Skills = skillModels;
     return PartialView("_SkillsPartial", skillCatalogModel);
 }