コード例 #1
0
 public AssignmentsController(IAssignmentsService assignmentsService, IStudentsService studentsService, UserManager <ApplicationUser> userManager, IFilesService filesService)
 {
     this.assignmentsService = assignmentsService;
     this.studentsService    = studentsService;
     this.userManager        = userManager;
     this.filesService       = filesService;
 }
コード例 #2
0
 public AssignmentsController(
     IUsersService usersService,
     IAssignmentsService assignmentsService)
 {
     this.usersService       = usersService;
     this.assignmentsService = assignmentsService;
 }
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            AssignmentsController controller = (AssignmentsController)context.Controller;
            ILogger logger = controller.GetLogger();

            try
            {
                var id           = Guid.Parse(CryptographicHelper.SymmetricDecrypt(context.ActionArguments["id"].ToString()));
                var loggedInUser = context.HttpContext.User.Identity.Name;

                IAssignmentsService assignmentsService = (IAssignmentsService)context.HttpContext.RequestServices.GetService(typeof(IAssignmentsService));


                if (loggedInUser != assignmentsService.GetSubmission(id).Member.Email&& !context.HttpContext.User.IsInRole("Teacher"))
                {
                    IPHostEntry iphostinfo = Dns.GetHostEntry(Dns.GetHostName());

                    string ipaddress = Convert.ToString(iphostinfo.AddressList.FirstOrDefault(address => address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork));

                    logger.LogInformation(loggedInUser + " on IP " + ipaddress + " tried to access submission with id " + id + ". Access was denied");

                    context.Result = new UnauthorizedObjectResult("Access Denied");
                }
            }
            catch (Exception ex)
            {
                logger.LogInformation("Bad request when user tried to access a file");
                context.Result = new BadRequestObjectResult("Bad Request");
            }

            base.OnActionExecuting(context);
        }
コード例 #4
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            try
            {
                //Passing the assignment Id
                var Id           = new Guid(context.ActionArguments["id"].ToString());
                var loggedInUser = context.HttpContext.User.Identity.Name;
                IAssignmentsService assignmentsService = (IAssignmentsService)context.HttpContext.RequestServices.GetService(typeof(IAssignmentsService));

                var assignment = assignmentsService.GetAssignmentById(Id);


                if (assignment.Student.Email == loggedInUser || assignment.Student.Teacher.Email == loggedInUser)
                {
                    base.OnActionExecuting(context);
                }
                else
                {
                    context.Result = new UnauthorizedObjectResult("Access Denied!");
                }
            }
            catch (Exception ex)
            {
                context.Result = new BadRequestObjectResult("bad request");
            }
        }
 public AssignmentsController(IAssignmentsService assignmentsService, IMembersService membersService, IWebHostEnvironment host, ILogger <AssignmentsController> logger)
 {
     _assignmentsService = assignmentsService;
     _membersService     = membersService;
     _host   = host;
     _logger = logger;
 }
コード例 #6
0
 public CommentsController(IAssignmentsService assignmentsService,
                           IStudentsService studentsService, ITeachersService teachersService, ICommentsService commentsService)
 {
     _assignmentsService = assignmentsService;
     _studentsService    = studentsService;
     _teachersService    = teachersService;
     _commentsService    = commentsService;
 }
コード例 #7
0
 public AssignmentsController(IAssignmentsService assignmentsService, IWebHostEnvironment host, ILogger <AssignmentsController> logger,
                              IStudentsService studentsService, ITasksService tasksService)
 {
     _assignmentsService = assignmentsService;
     _studentsService    = studentsService;
     _tasksService       = tasksService;
     _host   = host;
     _logger = logger;
 }
コード例 #8
0
        public StudentProfileViewModel(IAuthService authService, IAssignmentsService assignmentsService, IResultsService resultsService)
        {
            _authService        = authService;
            _assignmentsService = assignmentsService;
            _resultsService     = resultsService;

            selectedStudent    = _authService.authorisedUser;
            StudentAssignments = GetStudentAssignments();
        }
コード例 #9
0
        public LecturerStudentManagementViewModel(IAuthService authService, ILecturerService lecturerService, IUsersService usersService, IAssignmentsService assignmentsService, IResultsService resultsService)
        {
            _authService        = authService;
            _lecturerService    = lecturerService;
            _usersService       = usersService;
            _assignmentsService = assignmentsService;
            _resultsService     = resultsService;

            selectedLecturer = _authService.authorisedUser;
        }
コード例 #10
0
 public ProjectsService(OmmDbContext context, IReportsService reportsService, IStatusesService statusesService,
                        IEmployeesService employeesService, IProjectPositionsService projectPositionsService,
                        IEmployeesProjectsPositionsService employeesProjectsPositionsService, IAssignmentsService assignmentsService)
 {
     this.context                           = context;
     this.reportsService                    = reportsService;
     this.statusesService                   = statusesService;
     this.employeesService                  = employeesService;
     this.projectPositionsService           = projectPositionsService;
     this.employeesProjectsPositionsService = employeesProjectsPositionsService;
     this.assignmentsService                = assignmentsService;
 }
コード例 #11
0
 public ModulesController(
     IModulesService modulesService,
     ITutoringApplicationsService tutoringApplicationsService,
     IUsersService usersService,
     IStudentTutorsService studentTutorsService,
     IAssignmentsService assignmentsService)
 {
     _modulesService = modulesService;
     _tutoringApplicationsService = tutoringApplicationsService;
     _usersService         = usersService;
     _studentTutorsService = studentTutorsService;
     _assignmentsService   = assignmentsService;
 }
コード例 #12
0
        public AssignmentsServiceTests()
        {
            var setup = new UnitTestSetup();

            _userManager = setup.UserManager;
            _context     = setup.Context;

            var filesServiceMock = new Mock <IFilesService>();

            _currentUserServiceMock = new Mock <ICurrentUserService>();
            _currentUserServiceMock
            .Setup(s => s.GetUserId())
            .Returns(_userManager.Users.First(u => u.Email == "*****@*****.**").Id);

            _assignmentsService = new AssignmentsService(
                _currentUserServiceMock.Object,
                new AssignmentsRepository(setup.Context),
                new StudentTutorsRepository(setup.Context),
                filesServiceMock.Object
                );
        }
コード例 #13
0
 public AssignmentsController(IAssignmentsService assignments)
 {
     this.assignments = assignments;
 }
コード例 #14
0
 public SubmissionsController(ISubmissionsService submissions, IUsersService users, IAssignmentsService assignments)
 {
     this.submissions = submissions;
     this.users       = users;
     this.assignments = assignments;
 }
コード例 #15
0
 public AssignmentsController(IEmployeesService employeesService, IAssignmentsService assignmentsService)
 {
     this.employeesService   = employeesService;
     this.assignmentsService = assignmentsService;
 }
コード例 #16
0
 public Encryption(IAssignmentsService _assignmentsService)
 {
     _assignmentsService = assignmentsService;
 }
コード例 #17
0
 public AssignmentsController(IAssignmentsService assignmentsService)
 {
     this.assignmentsService = assignmentsService;
 }
コード例 #18
0
 public AssignmentsController(IAssignmentsService assignments, ICoursesService courses)
 {
     this.assignments = assignments;
     this.courses     = courses;
 }
コード例 #19
0
 public HomeController(IAssignmentsService assignmentsService, IOrdersService ordersService, UserManager <ApplicationUser> userManager)
 {
     this.assignmentsService = assignmentsService;
     this.ordersService      = ordersService;
     this.userManager        = userManager;
 }