public async Task <IActionResult> Get(Guid id) { var skill = await _skillService.GetByIdAsync(id); if (skill == null) { return(NotFound()); } return(Ok(skill)); }
public async Task <IActionResult> Edit(int id) { TempData["active"] = "skill"; var updatedSkill = await _skillService.GetByIdAsync(id); var activeCategory = await _categoryService.GetCategoryBySubCatIdAsync(updatedSkill.SubCategoryId); if (updatedSkill != null) { var skill = _mapper.Map <SkillGeneralDto>(updatedSkill); skill.CategoryList = new SelectList(await _categoryService.GetListAsync(), "Id", "Name", activeCategory.Id); skill.SubCategoryList = new SelectList(await _subCategoryService.GetListByFilterAsync(x => x.CategoryId == activeCategory.Id), "Id", "Name", updatedSkill.SubCategoryId); return(View(skill)); } return(BadRequest()); }
public async Task <ActionResult> EditSkill(int?id, string returnUrl) { if (id == null) { return(HttpNotFound("Missed id value")); } try { SkillDTO skillDTO = await _skillService.GetByIdAsync(id.Value); var skillViewModel = _mapper.Map <SkillDTO, SkillViewModel>(skillDTO); skillViewModel.ReturnUrl = string.IsNullOrWhiteSpace(returnUrl) ? Url.Action("Skills") : returnUrl; return(View(skillViewModel)); } catch (Exception ex) { return(HttpNotFound(ex.Message)); } // return RedirectToAction("Skills", new {ex.Message}); // todo returnUrl }
public async Task <IActionResult> GetAsync(int id) { var result = await _skillService.GetByIdAsync(id); if (!result.Success) { return(BadRequest(result.Message)); } var skillResource = _mapper.Map <Skill, SkillResource>(result.Resource); return(Ok(skillResource)); }
public static async Task AddCharacterSkillAsync(this IPlayerEntity player, CharacterSkillDto skill) { if (player.SkillComponent.CharacterSkills.ContainsKey(skill.Id)) { return; } player.SkillComponent.CharacterSkills.Add(skill.Id, skill); SkillDto skillDto = await SkillService.GetByIdAsync(skill.SkillId); player.SkillComponent.AddSkill(skillDto); }
public async Task <IActionResult> Edit(int id) { var skill = await _skillService.GetByIdAsync(id); if (skill == null) { return(NotFound()); } var editModel = new SkillEditViewModel { SkillId = skill.SkillId, SkillGroupId = skill.SkillGroupId, SkillTypeId = skill.SkillTypeId, SkillName = skill.SkillName, SkillDescription = skill.SkillDescription, SkillGroups = await _employeeDetailService.GetSkillGroups(), SkillTypes = await _employeeDetailService.GetSkillTypes() }; return(View(editModel)); }
public void GetAll() { Assert.IsTrue(_skillService.GetAll().ToList().Count == 3); Assert.AreEqual(_skillService.GetAll().ToList()[0].Name, "Nokia Lumia 630"); Assert.AreEqual(_skillService.GetByIdAsync(1).Result.Name, "Nokia Lumia 630"); }