Пример #1
0
        public async Task <IActionResult> Create([Bind("ID,first_name,last_name,email,phone,userID,password")] Mentor mentor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mentor);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(mentor));
        }
Пример #2
0
        public async Task <bool> ChangeCourseStatusAsync(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 = await context.SaveChangesAsync();

                    if (result > 0)
                    {
                        return(true);
                    }
                }
                else if (UserEmail == enrolledCourse.StudentEmail && enrolledCourse.Status == "Request Accepted")
                {
                    enrolledCourse.Status = "In Progress";
                    context.EnrolledCourses.Update(enrolledCourse);
                    int result = await context.SaveChangesAsync();

                    if (result > 0)
                    {
                        return(true);
                    }
                }

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