Example #1
0
        public async Task <IActionResult> DeleteUserSkill(UserSkillToRemoveDto userSkilltoRemove)
        {
            if (userSkilltoRemove.UserId != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var userSkill = await _repo.GetUserSkill(userSkilltoRemove.UserId, userSkilltoRemove.SkillName);

            if (userSkill == null)
            {
                return(BadRequest());
            }

            _repo.Delete(userSkill);

            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            else
            {
                return(BadRequest("Unable to remove the skill"));
            }
        }