public IActionResult Participate(int courseId)
        {
            ActionResult result = null;
            int          _role  = 0;

            if (IsAuthenticated)
            {
                _role = CurrentUser.RoleId;
                if (_role == 2)
                {
                    Course           crs   = _courseDAL.GetCourse(courseId);
                    List <Curricula> currs = (List <Curricula>)_currDAL.GetCurriculas(courseId);
                    List <List <CurriculaLineItem> > allLines = new List <List <CurriculaLineItem> >();

                    CourseFullDataViewModel ccvm = new CourseFullDataViewModel()
                    {
                        FullDataUserId    = CurrentUser.Id,
                        DisplayUser       = CurrentUser.FirstName,
                        Id                = crs.Id,
                        EstimatedDuration = crs.EstimatedDuration,
                        Description       = crs.Description,
                        Category          = crs.CategoryName,
                        MyCurricula       = currs,
                        TeacherFirstName  = crs.TeacherFirstName,
                        TeacherLastName   = crs.TeacherLastName,
                        TeacherId         = crs.TeacherId,
                        Name              = crs.Name
                    };

                    for (int i = 0; i < currs.Count; i++)
                    {
                        List <CurriculaLineItem> curlines = new List <CurriculaLineItem>();
                        curlines = (List <CurriculaLineItem>)_currDAL.GetCurriculaLineItems(ccvm.MyCurricula[i].Id);
                        allLines.Add(curlines);
                    }
                    ccvm.MyCurriculaLineItems = allLines;
                    result = View(ccvm);
                }
                else if (_role == 1)
                {
                    result = RedirectToAction("Dashboard", "Teacher", new { studentId = CurrentUser.Id });
                }
            }
            else
            {
                result = RedirectToAction("Login", "User");
            }
            return(result);
        }
Example #2
0
 public List <tb_course> GetCourse(string name)
 {
     return(dal.GetCourse(a => (!string.IsNullOrEmpty(name) ? a.name.Contains(name) : true)));
 }