public bool AddSkill(int courseId, SetAvailableCoursesDto mentordetails)
 {
     try
     {
         var course   = context.Courses.Where(c => c.Id == courseId).SingleOrDefault();
         var ifExists = context.AvailableCourses.Where(ac =>
                                                       ac.MentorEmail == mentordetails.Email && ac.CourseDetails == course).SingleOrDefault();
         if (ifExists == null)
         {
             var skill = new AvailableCourses
             {
                 CourseDetails = course,
                 MentorFname   = mentordetails.FName,
                 MentorLname   = mentordetails.LName,
                 MentorEmail   = mentordetails.Email
             };
             context.AvailableCourses.Add(skill);
             var result = context.SaveChanges();
             if (result > 0)
             {
                 return(true);
             }
             return(false);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw;
     }
 }
Example #2
0
 public bool AddCourse(Course crs)
 {
     try
     {
         var course = new Course
         {
             TechnologyId   = crs.TechnologyId,
             MentorId       = crs.MentorId,
             TechnologyName = crs.TechnologyName,
             Commission     = crs.Commission,
             StartDate      = crs.StartDate,
             EndDate        = crs.EndDate,
             CourseFee      = crs.CourseFee
         };
         context.Courses.Add(course);
         int result = context.SaveChanges();
         if (result > 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw;
     }
 }
        public bool AddCourse(CourseDto model)
        {
            var course = new Course
            {
                Name       = model.CName,
                Duration   = model.CDuration,
                Timing     = model.CTiming,
                Fees       = model.CFees,
                Technology = context.Technologies.Find(model.TId),
                Mentor     = context.MoDUsers.Find(model.MId)
            };

            try
            {
                context.Courses.Add(course);
                var result = context.SaveChanges();
                if (result > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch
            {
                throw;
            }
        }
Example #4
0
        //public IEnumerable<UserMod> GetUsers()
        //{
        //    return context.UserMods.ToList();
        //}

        //public IEnumerable<string> GetUsers()
        //{
        //    var users = from u in context.UserMods
        //                join r in context.UserRoles on u.Id equals r.UserId
        //                select r.RoleId;
        //    return users;
        //}



        public void PutAcceptRequest(int id)
        {
            var training = context.TrainingDtls.Find(id);

            training.accept = true;
            context.TrainingDtls.Update(training);
            context.SaveChanges();
        }
 public bool AddMentorTechnology(MentorTechnology mentortech)
 {
     try
     {
         context.MentorTechnologies.Add(mentortech);
         int result = context.SaveChanges();
         if (result == 1)
         {
             return(true);
         }
         return(false);
     }
     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;
            }
        }
Example #7
0
        public bool ChangeCourseStatus(EnrolledCourse enrolledCourse, string UserEmail)
        {
            try
            {
                if (UserEmail == enrolledCourse.MentorEmail)
                {
                    if (enrolledCourse.Status == "Requested")
                    {
                        enrolledCourse.Status = "Request Accepted";
                    }
                    else if (enrolledCourse.Status == "In Progress")
                    {
                        enrolledCourse.Status = "Completed";
                    }
                    context.EnrolledCourses.Update(enrolledCourse);
                    int result = context.SaveChanges();
                    if (result > 0)
                    {
                        return(true);
                    }
                }
                else if (UserEmail == enrolledCourse.StudentEmail && enrolledCourse.Status == "Request Accepted")
                {
                    enrolledCourse.Status = "In Progress";
                    context.EnrolledCourses.Update(enrolledCourse);
                    int result = context.SaveChanges();
                    if (result > 0)
                    {
                        return(true);
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                throw;
            }
        }