public IActionResult Post([FromBody] MentorSkill mentorSkill)
        {
            var result = repository.CreateSkill(mentorSkill);

            if (result)
            {
                return(Ok());
            }
            return(BadRequest());
        }
        public IActionResult MentorSkillExists([FromBody] MentorSkill mentorSkill)
        {
            var result = repository.MentorSkillExists(mentorSkill.TechId, mentorSkill.MentorEmail);

            if (result)
            {
                return(BadRequest("The Course is already created by you!"));
            }
            return(Ok());
        }
 public bool CreateSkill(MentorSkill mentorSkill)
 {
     try
     {
         context.MentorSkills.Add(mentorSkill);
         context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public async Task <int> AddSkill(MentorSkillAddDTO addSkillDTO)
        {
            try
            {
                var user = await userManager.FindByEmailAsync(addSkillDTO.Email);

                var tech = context.Technologies.Find(addSkillDTO.TechID);
                if (user == null || tech == null)
                {
                    return(2);
                }
                var isDublicate = context.MentorSkills.Where(ms => ms.User == user && ms.TechId == tech.TechId).FirstOrDefault();
                if (isDublicate == null)
                {
                    MentorSkill skill = new MentorSkill
                    {
                        User           = user,
                        TechId         = tech.TechId,
                        StartDate      = addSkillDTO.StartDate,
                        EndDate        = addSkillDTO.EndDate,
                        SkillSurcharge = addSkillDTO.SkillSurcharge,
                        TotalFee       = Convert.ToDecimal(tech.BasicFee * (1 + 0.01 * (tech.Commission + addSkillDTO.SkillSurcharge))),
                        Status         = true
                    };
                    context.MentorSkills.Add(skill);
                    int result = context.SaveChanges(); // returns number of changes
                    if (result > 0)
                    {
                        return(1); // success
                    }
                    return(2);     // error
                }
                else
                {
                    return(3); // duplicate request
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }