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"); }
public ActionResult SubmitSkillReplace(SubmittingUserSkill userSkill) { if (WebSecurity.IsAuthenticated) { var userId = WebSecurity.CurrentUserId; _skillRepository.UpdateUserSkill(userSkill.SkillId, userId, userSkill.NewMark); //todo: send update msg sendUpdateMsg(); } return RedirectToAction("Index"); }