public void DeletedAssignmentShoundNotExistInDatabase()
        {
            //Arrange
            NewAssignmentVm assignmentToAdd = new NewAssignmentVm()
            {
                Id   = 1,
                Name = "test"
            };

            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase("UsersDirectoryMVC")
                          .Options;

            var config = new MapperConfiguration(c =>
            {
                c.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            using (var context = new Context(options))
            {
                //Act
                var assignmentService = new AssignmentService(mapper, new AssignmentRepository(context));
                var result            = assignmentService.AddAssignment(assignmentToAdd);
                assignmentService.DeleteAssignment(1);
                var deletedAssignment = assignmentService.GetAssignmentDetails(1);

                //Assert
                deletedAssignment.Should().BeNull();
            }
        }
        public void CheckAssignmentIfExistAfterAdd()
        {
            //Arrange
            NewAssignmentVm assignmentToAdd = new NewAssignmentVm()
            {
                Id   = 1,
                Name = "test"
            };

            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase("UsersDirectoryMVC")
                          .Options;

            var config = new MapperConfiguration(c =>
            {
                c.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            using (var context = new Context(options))
            {
                //Act
                var assignmentService = new AssignmentService(mapper, new AssignmentRepository(context));
                var result            = assignmentService.AddAssignment(assignmentToAdd);

                //Assert
                context.Assignments.FirstOrDefaultAsync(e => e.Id == result).Should().NotBeNull();
            }
        }
        // CREATE ASSIGNMENT SERVICE
        private AssignmentService CreateAssignmentService()
        {
            var userID  = Guid.Parse(User.Identity.GetUserId());
            var service = new AssignmentService(userID);

            return(service);
        }
Exemplo n.º 4
0
 public HomeworkController(HomeworkServices homeworkServices, AssignmentService assignmentService, UserServices userServices, UserManager <IdentityUser> userManager)
 {
     this.homeworkServices   = homeworkServices;
     this.assignmentServices = assignmentService;
     this.userServices       = userServices;
     this.userManager        = userManager;
 }
Exemplo n.º 5
0
        public List <AssignmentViewModel> GetAllNonFocusAssignments(int employee)
        {
            List <AssignmentViewModel> AssignmentViewModels = new List <AssignmentViewModel>();

            List <Assigment> targetData = AssignmentService.GetAllNonFocus(employee);

            if (targetData != null)
            {
                foreach (Assigment target in targetData)
                {
                    AssignmentViewModel avm = new AssignmentViewModel
                    {
                        Id          = target.Id,
                        Beskrivning = target.Beskrivning,
                        Roll        = target.Roll,
                        Teknik      = target.Teknik,
                        Tid         = target.Tid,
                        Uppdrag     = target.Uppdrag,
                        Focus       = target.Focus
                    };

                    AssignmentViewModels.Add(avm);
                }
            }

            return(AssignmentViewModels);
        }
Exemplo n.º 6
0
        public void DoAssighment()
        {
            const string          InputLocation = "mockLocation";
            Dictionary <int, int> histDummy     = new Dictionary <int, int>
            {
                { 0, 3 },
                { 1, 1 }
            };

            double[] testSet        = new double[] { 3, 7, 7, 19 };
            var      dataLoaderMock = new Mock <IDataLoader>();

            dataLoaderMock.Setup(n => n.Load(InputLocation)).Returns(testSet);

            var statsServiceMock = new Mock <IStatsService>();

            statsServiceMock.Setup(n => n.CalcArithmeticMean(testSet)).Returns(9);
            statsServiceMock.Setup(n => n.CalcStandardDeviation(testSet)).Returns(6);
            statsServiceMock.Setup(n => n.GetHistogram(testSet)).Returns(histDummy);

            IAssignmentService service = new AssignmentService(dataLoaderMock.Object, statsServiceMock.Object);

            service.DoAssignment(InputLocation);

            dataLoaderMock.Verify(m => m.Load(InputLocation));
            statsServiceMock.Verify(n => n.CalcArithmeticMean(testSet));
            statsServiceMock.Verify(n => n.CalcStandardDeviation(testSet));
            statsServiceMock.Verify(n => n.GetHistogram(testSet));
        }
        private AssignmentService CreateAssignmentService()
        {
            var userId  = User.Identity.GetUserId();
            var service = new AssignmentService(userId);

            return(service);
        }
Exemplo n.º 8
0
        public async Task CreateAsyncCreatesOneEntity()
        {
            BaseServiceTests.Initialize();

            var repository = new DbRepository <Assignment>(dbFixture.dbContext);
            var service    = new AssignmentService(repository);

            var assgnCount = this.dbFixture.dbContext.Assignments.Count();

            var lecturecise   = this.dbFixture.dbContext.Lecturecises.First();
            var lectureciseId = lecturecise.Id;

            var educator   = this.dbFixture.dbContext.Educator.First();
            var educatorId = educator.Id;

            await service.CreateAsync(new AssignmentCreateBindingModel()
            {
                Name          = "Assgn2",
                MaxGrade      = 10m,
                EducatorId    = educatorId,
                LectureciseId = lectureciseId
            });

            Assert.Equal(assgnCount + 1, dbFixture.dbContext.Assignments.Count());
        }
        public ActionResult GetReportDetailData(SearchAssignmentStatusByUser search, int LevelIdentifier)
        {
            try
            {
                JsonResult jr = new JsonResult();
                ValidateSearchCriteria(search);

                List <AssignmentStatusByUser_EPData> DetailData = new List <AssignmentStatusByUser_EPData>();
                DetailData = AssignmentService.GetAssignmentStatusByUser_EPData(search);

                jr = Json(DetailData, JsonRequestBehavior.AllowGet);

                jr.MaxJsonLength  = Int32.MaxValue;
                jr.RecursionLimit = 100;
                return(jr);
            }

            catch (Exception ex)
            {
                ExceptionLog exceptionLog = new ExceptionLog
                {
                    ExceptionText = "Reports: " + ex.Message,
                    PageName      = "AssignmentStatusByUser",
                    MethodName    = "GetReportData",
                    UserID        = Convert.ToInt32(AppSession.UserID),
                    SiteId        = Convert.ToInt32(AppSession.SelectedSiteId),
                    TransSQL      = "",
                    HttpReferrer  = null
                };
                exceptionService.LogException(exceptionLog);

                return(RedirectToAction("Error", "Transfer"));
            }
        }
Exemplo n.º 10
0
        public async Task ReturnsCourseById()
        {
            // Arrange
            var data = this.GetData();

            var course = new Course();

            var mockedSet = new Mock <DbSet <Course> >();

            mockedSet.As <IQueryable <Course> >().Setup(m => m.Provider).Returns(data.Provider);
            mockedSet.As <IQueryable <Course> >().Setup(m => m.Expression).Returns(data.Expression);
            mockedSet.As <IQueryable <Course> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockedSet.As <IQueryable <Course> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
            mockedSet.Setup(a => a.FindAsync(It.IsAny <object>())).ReturnsAsync(course);

            var contextMock = new Mock <ApplicationDbContext>();

            contextMock.Setup(c => c.Courses).Returns(mockedSet.Object);

            var service = new AssignmentService(contextMock.Object);

            // Act
            var result = await service.GetById(1);

            // Assert
            Assert.AreEqual(course, result);
        }
Exemplo n.º 11
0
        public void AddAssignment()
        {
            //Q: can we add an assignment?

            //prep
            var _context       = new MackTechGroupProject.Models.ApplicationDbContext();
            int courseId       = 34;
            var selectedCourse = _context.Courses.Where(x => x.CourseId == courseId).FirstOrDefault();
            //Guid assignmentGuid = Guid.NewGuid();

            var assignment = new Assignment
            {
                Course                = selectedCourse,
                Points                = 100,
                AssignmentTitle       = "Unit Test",
                AssignmentDescription = "Unit Test added course",
                DueDate               = DateTime.Now,
                SubmissionType        = "Text-Submission",
                AssignmentAddedOn     = DateTime.Now
            };

            //perform operations
            Boolean result = AssignmentService.AddAssignmentService(courseId, assignment, _context);

            //verify and interpret results
            Assert.IsTrue(result);

            var y = _context.Assignments.Where(x => x.AssignmentId == assignment.AssignmentId);

            System.Diagnostics.Debug.WriteLine(y.Count());
            Assert.IsTrue(y.Count() == 1);
        }
 public AssignmentsController(UserService userService, CourseService courseService, AssignmentService assignmentService, AnnouncementService announcementService)
 {
     _userService         = userService;
     _courseService       = courseService;
     _assignmentService   = assignmentService;
     _announcementService = announcementService;
 }
Exemplo n.º 13
0
        public void CheckAssignmentIdAfterAdd()
        {
            //Arrange
            NewAssignmentVm assignmentToAdd = new NewAssignmentVm()
            {
                Id   = 6,
                Name = "test",
            };

            Assignment assignment = new Assignment()
            {
                Id   = 6,
                Name = "test"
            };

            var config = new MapperConfiguration(c =>
            {
                c.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            var mock = new Mock <IAssignmentRepository>();

            mock.Setup(s => s.AddAssignment(assignment)).Returns(assignment.Id);

            var manager = new AssignmentService(mapper, mock.Object);

            //Act
            var result = manager.AddAssignment(assignmentToAdd);

            //Assert
            result.Should().Equals(assignment.Id);
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Edit(int id, int?createdQuestionId = null)
        {
            var assignment = await AssignmentService.GetAssignmentAsync(ClassroomName, id);

            if (assignment == null)
            {
                return(NotFound());
            }

            if (createdQuestionId != null)
            {
                var createdQuestion = await QuestionService.GetQuestionAsync
                                      (
                    ClassroomName,
                    createdQuestionId.Value
                                      );

                assignment.Questions.Add
                (
                    new AssignmentQuestion()
                {
                    Name       = createdQuestion.Name,
                    Order      = assignment.Questions.Count,
                    Question   = createdQuestion,
                    QuestionId = createdQuestion.Id
                }
                );
            }

            await PopulateDropDownsAsync(assignment);

            return(View("CreateEdit", assignment));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Index(int?userId)
        {
            if (userId == null)
            {
                userId = User.Id;
            }

            if (userId != User.Id && ClassroomRole != ClassroomRole.Admin)
            {
                return(Forbid());
            }

            var results = await AssignmentService.GetStudentAssignmentResultsAsync
                          (
                ClassroomName,
                userId.Value,
                ClassroomRole == ClassroomRole.Admin
                          );

            var viewModel = new StudentAssignmentsViewModel
                            (
                results,
                GetAssignmentDisplayProviderFactory()
                            );

            return(View(viewModel));
        }
Exemplo n.º 16
0
        public async Task <ActionResult <AssignmentDto> > UpdateAssignment(UpdateAssignmentDto assignmentDto)
        {
            if (assignmentDto == null)
            {
                return(BadRequest(InvalidAssignmentError));
            }
            if (assignmentDto.Start >= assignmentDto.End)
            {
                return(BadRequest("Start time was on or after end time."));
            }
            var savedAssignment = await AssignmentService.GetAssignment(assignmentDto.Id);

            if (savedAssignment == null)
            {
                return(NotFound());
            }
            if (!PermissionDataFiltersExtensions.HasAccessToLocation(User, Db, savedAssignment.LocationId))
            {
                return(Forbid());
            }

            var updateAssignment  = assignmentDto.Adapt <Assignment>();
            var updatedAssignment = await AssignmentService.UpdateAssignment(updateAssignment);

            return(Ok(updatedAssignment.Adapt <AssignmentDto>()));
        }
Exemplo n.º 17
0
 public AssignmentServiceClient()
 {
     stub                 = new AssignmentService();
     stub.Credentials     = new System.Net.NetworkCredential(WEBSERVICE_LOGIN, WEBSERVICE_PASSWORD);
     stub.PreAuthenticate = true;
     stub.Url             = WEBSERVICE_URL;
 }
Exemplo n.º 18
0
        public async Task <IActionResult> Get(string startDate, string endDate)
        {
            AssignmentService assignmentService = new AssignmentService();
            var response = await assignmentService.GetResponse(startDate, endDate);

            return(this.Ok(response));
        }
Exemplo n.º 19
0
	private void Start ()
	{
		CallNotificationsAuctionsService ();
		assigmentService = new AssignmentService ();
		assigmentService.SucceededEvent += GetAssigmentNotifications;
		assigmentService.StartService (Helpers.GetDeviceID (),serverSettings);
	}
Exemplo n.º 20
0
        // GET: Assigments
        public IActionResult Index()
        {
            List <AssignmentViewModel> AssignmentViewModels = new List <AssignmentViewModel>();
            List <Assigment>           targetData           = AssignmentService.GetEvery();

            if (targetData != null)
            {
                foreach (Assigment target in targetData)
                {
                    Employee            employee = EmployeeService.Get(target.Employeeid);
                    AssignmentViewModel avm      = new AssignmentViewModel
                    {
                        Id          = target.Id,
                        Employee    = employee,
                        Beskrivning = target.Beskrivning,
                        Roll        = target.Roll,
                        Teknik      = target.Teknik,
                        Tid         = target.Tid,
                        Uppdrag     = target.Uppdrag,
                        Focus       = target.Focus
                    };
                    if (employee == null)
                    {
                        Employee temp = new Employee();
                        temp.EmployeeId   = 0;
                        temp.EmployeeName = "INTE KOPPLAD TILL NÅGON ANSTÄLLD";
                        avm.Employee      = temp;
                    }
                    AssignmentViewModels.Add(avm);
                }
            }
            var sortedlist = AssignmentViewModels.OrderBy(foo => foo.Employee.EmployeeName).ToList();

            return(View(sortedlist));
        }
        public void CheckAssignmentToEditDetailsAreEqualLikeModel()
        {
            //Arrange
            NewAssignmentVm assignmentToAdd = new NewAssignmentVm()
            {
                Id   = 1,
                Name = "test"
            };

            var config = new MapperConfiguration(c =>
            {
                c.AddProfile(new MappingProfile());
            });
            var mapper = config.CreateMapper();

            var options = new DbContextOptionsBuilder <Context>()
                          .UseInMemoryDatabase("UsersDirectoryMVC")
                          .Options;


            using (var context = new Context(options))
            {
                //Act
                var assignmentService = new AssignmentService(mapper, new AssignmentRepository(context));
                assignmentService.AddAssignment(assignmentToAdd);
                var result = assignmentService.GetAssignmentForEdit(1);

                //Assert
                result.Should().NotBeNull();
                result.Should().Equals(assignmentToAdd);
                context.Employers.FirstOrDefaultAsync(e => e.Id == result.Id).Should().NotBeNull();
            }
        }
        // GET: Assignment
        public ActionResult Index(string sortingOrder)
        {
            var userID  = Guid.Parse(User.Identity.GetUserId());
            var service = new AssignmentService(userID);

            //var model = service.GetAllAssignments();

            ViewBag.SortingSchoolName = string.IsNullOrEmpty(sortingOrder) ? "SchoolName" : "";
            ViewBag.SortingScoutName  = string.IsNullOrEmpty(sortingOrder) ? "ScoutName" : "";
            ViewBag.SortingCompleted  = string.IsNullOrEmpty(sortingOrder) ? "Completed" : "";

            var assignments = from assignment in service.GetAllAssignments() select assignment;

            switch (sortingOrder)
            {
            case "SchoolName":
                assignments = assignments.OrderBy(assignment => assignment.School.SchoolName);
                break;

            case "ScoutName":
                assignments = assignments.OrderBy(assignment => assignment.Scout.LastName);
                break;

            case "Completed":
                assignments = assignments.OrderBy(assignment => assignment.Completed);
                break;
            }

            return(View(assignments.ToList()));

            //return View(model);
        }
Exemplo n.º 23
0
        public HttpResponseMessage GetAssignmentById(int id)
        {
            ItemResponse <Assignment> response = new ItemResponse <Assignment>();

            response.Item = AssignmentService.SelectAssignmentById(id);

            return(Request.CreateResponse(response));
        }
Exemplo n.º 24
0
        public HttpResponseMessage GetAssignmentsByPeriod(int period)
        {
            ItemsResponse <Assignment> response = new ItemsResponse <Assignment>();

            response.Items = AssignmentService.GetAssignmentsByPeriod(period);

            return(Request.CreateResponse(response));
        }
Exemplo n.º 25
0
        public ActionResult DeleteByEmployee(int id)
        {
            Assigment assignment = AssignmentService.Get(id);

            AssignmentService.Delete(assignment);

            return(RedirectToAction("Cv", "Home", new { id = assignment.Employeeid }));
        }
Exemplo n.º 26
0
        public HttpResponseMessage GetAllAssignments()
        {
            ItemsResponse <Assignment> response = new ItemsResponse <Assignment>();

            response.Items = AssignmentService.GetAllAssignments();

            return(Request.CreateResponse(response));
        }
Exemplo n.º 27
0
        public HttpResponseMessage DeleteAssignmentById(int id)
        {
            SuccessResponse response = new SuccessResponse();

            AssignmentService.DeleteAssignmentById(id);

            return(Request.CreateResponse(response));
        }
Exemplo n.º 28
0
        public ActionResult CreateByEmployee(int employeeid, string uppdrag, string roll, string tid, string beskrivning, string teknik, string focus)
        {
            Assigment assignment = new Assigment(employeeid, uppdrag, roll, tid, beskrivning, teknik, check(focus));

            AssignmentService.Add(assignment);

            return(RedirectToAction("Cv", "Home", new { id = employeeid }));
        }
Exemplo n.º 29
0
        // GET: Assignment
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new AssignmentService(userId);
            var model   = service.GetAssignments();

            return(View(model));
        }
 public AssignmentsController(AssignmentService assignmentService,
                              UserManager <ApplicationUser> userManager,
                              IHostingEnvironment hostingEnvironment)
 {
     _assignmentService  = assignmentService;
     _userManager        = userManager;
     _hostingEnvironment = hostingEnvironment;
 }
Exemplo n.º 31
0
 public AssignmentsController(AssignmentService assignmentService, ClassroomService classroomService, LessonService lessonService, IAuthorizationService authorizationService, ApplicationDbContext dbContext)
 {
     _assignmentService    = assignmentService;
     _classroomService     = classroomService;
     _lessonService        = lessonService;
     _authorizationService = authorizationService;
     _dbContext            = dbContext;
 }