public IActionResult Post([FromBody] MentorSkillAddDTO addSkillDTO)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var result = repository.AddSkill(addSkillDTO);
         if (result.Result == 1)
         {
             return(Created("AddSkill", new { Message = $"{addSkillDTO.Name} added to your skills successfully" }));
         }
         else if (result.Result == 3)
         {
             return(BadRequest(new
             {
                 Message = $"Duplicate skill entry, {addSkillDTO.Name} is already added to your skills. Check My Skills."
             }));
         }
         return(BadRequest(result));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
Exemplo n.º 2
0
 public IActionResult Addskills(int courseId, [FromBody] SetAvailableCoursesDto mentordetails)
 {
     try
     {
         var result = repository.AddSkill(courseId, mentordetails);
         if (result)
         {
             return(Ok(new { Message = "Skill added successfully." }));
         }
         return(BadRequest(new { Message = "Internal Server error or Dublicate error." }));
     }
     catch (Exception e)
     {
         return(BadRequest(new { Message = "Internal Server error" }));
     }
 }