예제 #1
0
        public ActionResult NewAssignment(CreateAssignmentViewModel model, String courseId)
        {
            ActionResult result;

            model.CourseId = int.Parse(courseId);

            //Validate the model before proceeding
            if (!ModelState.IsValid)
            {
                result = View("Dashboard", model);
            }
            else
            {
                //valid
                Assignment assignment = new Assignment
                {
                    Instructions   = model.Instructions,
                    AssignmentId   = model.AssignmentId,
                    CourseId       = model.CourseId,
                    AssignmentName = model.AssignmentName
                };

                assignment = _db.CreateAssignment(assignment);
                assignment = _db.GetAssignmentId(assignment.AssignmentName);
                _db.CreateFileForTeacherAssignment(model.PostedFile, assignment.AssignmentId);
                _db.UpdateAssignmentWithFileId(assignment.AssignmentId);

                result = RedirectToAction("DashboardTeacherAssignment", new { courseId = int.Parse(courseId) });
            }
            return(result);
        }
예제 #2
0
        public ActionResult _CreateAssignment()
        {
            CreateAssignmentViewModel model = new CreateAssignmentViewModel();

            if (!IsTeacher)
            {
                RedirectToAction("NotAuth", "Home");
            }

            return(View("_CreateAssignment", model));
        }