コード例 #1
0
 public LoginViewModel() 
 {
     loginService = new LoginService();
     courseService = new CourseService();
     userDao = new UserDao();
     courseDao = new CourseDao();
 }
コード例 #2
0
        public void Setup()
        {
            mockCourseRepository = new Mock<CourseRepository>();
            mockCourseTakenRepository = new Mock<CourseTakenRepository>();
            service = new DomainCourseService(mockCourseRepository.Object, mockCourseTakenRepository.Object);
            coursesTaken = new List<CourseTakenModel>();
            courseId = Guid.NewGuid();

            mockCourseTakenRepository.Setup(r => r.FindCourses(courseId)).Returns(coursesTaken);
        }
コード例 #3
0
        /// <summary>
        /// SCORM Engine Service constructor that takes a single configuration parameter
        /// </summary>
        /// <param name="config">The Configuration object to be used to configure the Scorm Engine Service client</param>
        public ScormEngineService(Configuration config)
        {
            System.Net.ServicePointManager.Expect100Continue = false;

            configuration = config;
            courseService = new CourseService(configuration, this);
            dispatchService = new DispatchService(configuration, this);
            registrationService = new RegistrationService(configuration, this);
            invitationService = new InvitationService(configuration, this);
            uploadService = new UploadService(configuration, this);
            ftpService = new FtpService(configuration, this);
            exportService = new ExportService(configuration, this);
            reportingService = new ReportingService(configuration, this);
            debugService = new DebugService(configuration, this);
        }
コード例 #4
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="context"></param>
 public void DelCourse(HttpContext context)
 {
     var zwJson = new ZwJson();
     CourseService courseService = new CourseService(_session);
     var id = context.Request.Params["id"];
     var idlist = id.Split('|');
     foreach (var s in idlist)
     {
         var list = courseService.GetCourse(s);
         var count = list.Resourceses.Count();
         if (count > 0)
         {
             zwJson.IsSuccess = false;
             zwJson.Msg = list.Title + "课程下有资源文件,请先删除该文件,再点击删除!";
             context.Response.Write(_jss.Serialize(zwJson));
             return;
         }
         courseService.Delete(list);
     }
     zwJson.IsSuccess = true;
     zwJson.JsExecuteMethod = "Ajax_DelCourse";
     context.Response.Write(_jss.Serialize(zwJson));
 }
 public StudentsController(StudentService sService, CourseService cService)
 {
     _studentService = sService;
     _courseService  = cService;
 }
コード例 #6
0
        protected async override Task OnInitializedAsync()
        {
            Courses = await CourseService.GetCourses();

            //Doctors= (await CourseService.GetDotorsForCourse(course.Id)).ToList()
        }
コード例 #7
0
ファイル: CartService.cs プロジェクト: dKluev/Site
        public CartVM GetCart(decimal?orderId = null, bool addTrackDiscounts = false)
        {
            Entities.Context.Order order = null;
            Entities.Context.Order planOrder;
            if (orderId.HasValue)
            {
                order     = OrderService.GetByPK(orderId.Value);
                planOrder = OrderService.GetCurrentOrder(true) ?? new Entities.Context.Order();
            }
            else
            {
                order     = OrderService.GetCurrentOrder() ?? new Entities.Context.Order();
                planOrder = OrderService.GetCurrentOrder(true) ?? new Entities.Context.Order();
            }

            var trainer = EmployeeService.AllEmployees().GetValueOrDefault(order.FavoriteTeacher1);

            var cart = new CartVM(order)
            {
                InPlan     = new OrderSeparator(planOrder),
                User       = AuthService.CurrentUser,
                FavTrainer = trainer.GetOrDefault(x => x.FullName)
            };

            if (cart.OnlyIsCompaty &&
                order.CustomerType == OrderCustomerType.PrivatePerson)
            {
                UpdateOrder(OrderCustomerType.Organization);
            }

            cart.CourseTCHasExtrases = order.OrderDetails.Where(od => od.Track_TC == null &&
                                                                ExtrasService.GetFor(od).Any()).Select(od => od.Course_TC).ToList();

            cart.ExtrasTexts = ExtrasService.Texts();
            cart.IsNearestGroupOrderDetails = order.OrderDetails.Where(x =>
                                                                       x.Group_ID.HasValue && GroupService.GetGroupsForCourse(x.Course_TC)
                                                                       .FirstOrDefault().GetOrDefault(g => g.Group_ID == x.Group_ID))
                                              .Select(x => x.OrderDetailID).ToList();

            if (addTrackDiscounts && order.CustomerType != OrderCustomerType.Organization &&
                !cart.OnlyIsCompaty)
            {
                var trackInCart = order.OrderDetails.Where(x => x.Track_TC != null).Select(x => x.Track_TC).ToList();
                var courseTCs   = order.OrderDetails.Where(x => x.Track_TC.IsEmpty()).Select(x => x.Course_TC).ToList();
                if (courseTCs.Any())
                {
                    var trackCourses = CourseService.GetActiveTrackCourses().Select(x =>
                                                                                    new { x.Key, CourseCount = x.Value.Intersect(courseTCs).Count() })
                                       .Where(x => x.CourseCount > 0).ToDictionary(x => x.Key, x => x.CourseCount);
                    var trackTCs       = trackCourses.Select(x => x.Key).Where(tc => !trackInCart.Contains(tc)).ToList();
                    var tracks         = CourseService.GetAll(x => trackTCs.Contains(x.Course_TC)).ToList();
                    var trackDiscounts = TrackService.GetTrackDiscounts(tracks)
                                         .OrderByDescending(x => trackCourses[x.Track.Course_TC]).ThenBy(x => x.Price);
                    cart.TrackDiscounts = trackDiscounts.ToList();
                }

                var allOrderCourseTCs = order.OrderDetails.Select(x => x.Course_TC).ToList();
                cart.WithWebinar =
                    allOrderCourseTCs.Where(x => PriceService.GetAllPricesForCourse(x, null).Any(y => y.IsWebinar)).ToList();
            }

            return(cart);
        }
コード例 #8
0
 public TextToCommandParser(CourseService courseService)
 {
     _courseService = courseService;
 }
コード例 #9
0
ファイル: CourseController.cs プロジェクト: JL0619/Contoso
 public CourseController()
 {
     _courseService = new CourseService();
 }
コード例 #10
0
ファイル: CourseConverter.cs プロジェクト: weedkiller/NINE
        /// <summary>
        ///
        /// </summary>
        public CourseSummaryDto ConvertSummary(Course course)
        {
            var dto = new CourseSummaryDto();

            var courseService = new CourseService(_db);

            var summary = courseService.GetCourseSummary(course);

            dto.Id          = course.Id;
            dto.Name        = course.Name;
            dto.ShortName   = course.ShortName;
            dto.Description = course.Description;
            dto.IsCoterie   = course.Occurrence.IsCoterie;
            dto.HasHomeBias = course.Occurrence.HasHomeBias;

            foreach (var host in summary.Lecturers)
            {
                var lecturer = new LecturerDto();
                lecturer.FirstName = host.FirstName;
                lecturer.LastName  = host.Name;
                lecturer.Title     = host.Title;

                if (!string.IsNullOrEmpty(host.UrlProfile))
                {
                    lecturer.AddAction("Profile", host.UrlProfile);
                }

                if (dto.Lecturer == null)
                {
                    dto.Lecturer = new List <LecturerDto>();
                }

                dto.Lecturer.Add(lecturer);
            }

            foreach (var room in summary.Rooms)
            {
                var courseRoom = new RoomDto();

                courseRoom.Number   = room.Number;
                courseRoom.Building = room.Number.Substring(0, 1);

                if (courseRoom.Number.StartsWith("K") || courseRoom.Number.StartsWith("L"))
                {
                    courseRoom.Campus = "Pasing";
                }
                else if (courseRoom.Number.StartsWith("F"))
                {
                    courseRoom.Campus = "Karlstrasse";
                }
                else
                {
                    courseRoom.Campus = "Lothstrasse";
                }

                if (dto.Locations == null)
                {
                    dto.Locations = new List <RoomDto>();
                }

                dto.Locations.Add(courseRoom);
            }

            foreach (var activityDate in summary.Dates)
            {
                var courseDate = new AppointmentDto();

                courseDate.DayOfWeekName = activityDate.DayOfWeek.ToString();
                courseDate.TimeBegin     = activityDate.StartTime.ToString();
                courseDate.TimeEnd       = activityDate.EndTime.ToString();

                if (dto.Appointments == null)
                {
                    dto.Appointments = new List <AppointmentDto>();
                }

                dto.Appointments.Add(courseDate);
            }


            foreach (var nexus in course.Nexus)
            {
                var module = new ModuleDto();

                var curr = new CurriculumDto();

                curr.Name      = nexus.Requirement.Option.Package.Curriculum.Name;
                curr.ShortName = nexus.Requirement.Option.Package.Curriculum.ShortName;

                curr.Organiser           = new OrganiserDto();
                curr.Organiser.Name      = nexus.Requirement.Option.Package.Curriculum.Organiser.Name;
                curr.Organiser.ShortName = nexus.Requirement.Option.Package.Curriculum.Organiser.ShortName;
                curr.Organiser.Color     = nexus.Requirement.Option.Package.Curriculum.Organiser.HtmlColor;

                module.Id         = nexus.Requirement.Id;
                module.Curriculum = curr;
                module.Ects       = nexus.Requirement.ECTS;
                module.UsCredits  = nexus.Requirement.USCredits;
                module.Sws        = nexus.Requirement.SWS;


                if (dto.Modules == null)
                {
                    dto.Modules = new List <ModuleDto>();
                }

                dto.Modules.Add(module);
            }



            return(dto);
        }
コード例 #11
0
 public AddStudentToCourseCommand(CourseService courseService, string courseId, string studentEmail)
 {
     _courseService = courseService;
     _courseId      = courseId;
     _studentEmail  = studentEmail;
 }
コード例 #12
0
 public CourseController(CourseService courseService, DepartmentService departmentService)
 {
     _courseService     = courseService;
     _departmentService = departmentService;
 }
コード例 #13
0
        /// <summary>
        /// 根据CourseId获取数据
        /// </summary>
        /// <param name="context"></param>
        public void FindById(HttpContext context)
        {
            var zwJson = new ZwJson();
            CourseService courseService = new CourseService(_session);
            var id = context.Request.Params["id"];

            var data = courseService.GetCourse(id);
            data.ClickCount++;
            courseService.SaveOrUpdate(data);

            var course = courseService.FindById(id);
            zwJson.Data = course;
            zwJson.IsSuccess = true;
            zwJson.JsExecuteMethod = "Ajax_FindById";
            context.Response.Write(_jss.Serialize(zwJson));
        }
コード例 #14
0
 /// <summary>
 /// 保存课程
 /// </summary>
 /// <param name="context"></param>
 public void SaveCourse(HttpContext context)
 {
     var zwJson = new ZwJson();
     var course = new Model.Course
         {
             Id = Guid.NewGuid().ToString(),
             Contents = context.Request.Params["content"],
             CreateDt = DateTime.Now,
             Title = context.Request.Params["title"],
             Creater = context.Session["UserName"].ToString(),
             ClickCount = 0
         };
     CourseService courseService = new CourseService(_session);
     courseService.Save(course);
     zwJson.IsSuccess = true;
     zwJson.JsExecuteMethod = "Ajax_SaveCourse";
     context.Response.Write(_jss.Serialize(zwJson));
 }
コード例 #15
0
 /// <summary>
 /// 获取课程和资源
 /// </summary>
 /// <param name="context"></param>
 public void GetCourseAndResource(HttpContext context)
 {
     var zwJson = new ZwJson();
     CourseService courseService = new CourseService(_session);
     var type = context.Request.Params["type"];
     var course = courseService.GetCourseAndResource();
     zwJson.Data = from c in course
                   select new
                       {
                           c.Id,
                           c.Title,
                           Resourceses = c.Resourceses.Where(s => s.Flag == type)
                       };
     zwJson.IsSuccess = true;
     zwJson.JsExecuteMethod = "Ajax_GetCourseAndResource";
     context.Response.Write(_jss.Serialize(zwJson));
 }
コード例 #16
0
 /// <summary>
 /// 获取课程列表
 /// </summary>
 /// <param name="context"></param>
 public void GetCourse(HttpContext context)
 {
     var zwJson = new ZwJson();
     CourseService courseService = new CourseService(_session);
     var list = courseService.GetView();
     zwJson.Data = list;
     zwJson.IsSuccess = true;
     zwJson.JsExecuteMethod = "HtmlCourse";
     context.Response.Write(_jss.Serialize(zwJson));
 }
コード例 #17
0
        private void btnSaveResult_Click(object sender, EventArgs e)
        {
            try
            {
                var level    = LevelService.GetItem(LevelId);
                var semester = SemesterService.GetSemester(SemesterId).Name;
                var course   = CourseService.GetCourse(CourseId).Code;

                if (level.SectionModels != null && level.SectionModels.Count > 0)
                {
                    var message      = $@"Upload Details {Environment.NewLine}Level: {level.Name}{Environment.NewLine}Semester: {semester}{Environment.NewLine}Course: {course}{Environment.NewLine}Number of student: {_resultTemplateDownloadModels.Count}";
                    var dialogResult = this.ShowMessageBox(message, @"Data Upload Details", MessageBoxButtons.OKCancel, RadMessageIcon.Info);

                    if (dialogResult == DialogResult.OK)
                    {
                        var results          = new List <ResultModel>();
                        var studentProcessed = $@"Student Processed: {Environment.NewLine}";
                        var studentInDb      = $@"Student with result: {Environment.NewLine}";

                        foreach (var resultSingleStudentTemplateDownloadModel in _resultTemplateDownloadModels)
                        {
                            var studentModel = AspNetUserService.GetStudentId(resultSingleStudentTemplateDownloadModel.MatricNumber);
                            var courseModel  = CourseService.GetCourse(CourseId);
                            if (string.IsNullOrWhiteSpace(resultSingleStudentTemplateDownloadModel.MatricNumber))
                            {
                                continue;
                            }

                            if (courseModel == null)
                            {
                                continue;
                            }
                            var courseWithResult = ResultService.CanSaveResult(studentModel.Id, courseModel.Id);
                            if (courseWithResult != null)
                            {
                                studentInDb += $"{studentModel.MatricNumber}: {courseWithResult.Score} {Environment.NewLine}";
                                continue;
                            }

                            var result = new ResultModel
                            {
                                SectionId = level.SectionModels.FirstOrDefault().Id,
                                CourseId  = courseModel.Id,
                                StudentId = studentModel.Id,
                                Score     = resultSingleStudentTemplateDownloadModel.Score,
                                CreatedAt = DateTime.UtcNow
                            };
                            results.Add(result);
                            studentProcessed += $"{studentModel.MatricNumber}: {result.Score} {Environment.NewLine}";
                        }

                        ResultService.CreateBulk(results);
                        this.ShowMessageBox($@"{studentProcessed}{Environment.NewLine}{studentInDb}", @"Result Successed", MessageBoxButtons.OK, RadMessageIcon.Info);
                    }
                }
                else
                {
                    this.ShowMessageBox(@"Ensure that LEVEL selected has a SESSION attached to it.", "Upload Error", MessageBoxButtons.OK, RadMessageIcon.Error);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Error Message: " + ex.Message, ex);
                this.ShowMessageBox($@"Message: {ex.Message}{Environment.NewLine}Stack Message: {ex.StackTrace}", $@"Error Message from {typeof(SingleStudentSemesterResult)}");
            }
        }
コード例 #18
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                btnSaveResult.Enabled = true;
                var level = LevelService.GetLevelId((string)ddLevel.SelectedValue);

                if (level.SectionModels != null && level.SectionModels.Count > 0)
                {
                    if (TextHelper.ContainsValue(new List <string>
                    {
                        beResultTemplate.Value
                    }))
                    {
                        lblError.Text         = @"Result data is not selected";
                        btnSaveResult.Enabled = false;
                        return;
                    }

                    var dataRows = FileHelper.GetDataFromFile(beResultTemplate.Value);
                    var models   = new List <ResultSingleCourseTemplateDownloadModel>();

                    var rowIndex = 2;
                    foreach (var row in dataRows)
                    {
                        try
                        {
                            var institutionModel = new ResultSingleCourseTemplateDownloadModel
                            {
                                MatricNumber = row["Student"].ToString(),
                                Score        = Convert.ToInt32(row["Score"].ToString() ?? "0")
                            };
                            models.Add(institutionModel);
                        }
                        catch (Exception ex)
                        {
                            btnSaveResult.Enabled = false;
                            MessageBox.Show(ex.Message);
                        }
                    }

                    gridSingleStudentResult.DataSource          = models;
                    _resultTemplateDownloadModels               = models;
                    gridSingleStudentResult.Enabled             = true;
                    gridSingleStudentResult.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                    SemesterId = SemesterService.GetSemesterId((string)ddlSemester.SelectedValue);
                    LevelId    = level.Id;
                    CourseId   = CourseService.GetCourseByName((string)ddlCourse.SelectedValue).Id;
                }
                else
                {
                    btnSaveResult.Enabled = false;
                    this.ShowMessageBox(@"Ensure that LEVEL selected has a SESSION attached to it.", "Upload Error", MessageBoxButtons.OK, RadMessageIcon.Error);
                }
            }
            catch (Exception ex)
            {
                btnSaveResult.Enabled = false;
                _logger.Error("Error Message: " + ex.Message, ex);
                this.ShowMessageBox($@"Message: {ex.Message}{Environment.NewLine}Stack Message: {ex.StackTrace}", $@"Error Message from {typeof(SingleStudentSemesterResult)}");
            }
        }
コード例 #19
0
        // public readonly FileService _fileService;

        public GradesController(GradeService gradeservice, AnnouncementService announcementService, CourseService courseService, IWebHostEnvironment webHostEnvironment /*, FileService fileService*/)
        {
            _gradeservice        = gradeservice;
            _announcementService = announcementService;
            _courseService       = courseService;
            _webHostEnvironment  = webHostEnvironment;
            //_fileService = fileService;
        }
コード例 #20
0
 public CoursesController(CourseService courseService)
 {
     _courseService = courseService;
 }
コード例 #21
0
 public GradeController(CourseService courseService, IDbService dbService, UserService userService)
 {
     _courseService = courseService;
     _dbService     = dbService;
     _userService   = userService;
 }
コード例 #22
0
 public CartsController(CartRepository cartRepository, CourseService courseService, IMapper mapper)
 {
     this.cartRepository = cartRepository;
     this.courseService  = courseService;
     this.mapper         = mapper;
 }
コード例 #23
0
ファイル: AdminController.cs プロジェクト: paicustefan12/GMYK
 public AdminController(LearnerService learnerService,
                        CourseService courseService)
 {
     _learnerService = learnerService;
     _courseService  = courseService;
 }
コード例 #24
0
 public SearchViewModel(CourseService courseService)
 {
     _courseService = courseService;
 }
コード例 #25
0
 public CourseController(CourseService courseService, SessionsService sessionsService)
 {
     _courseService   = courseService;
     _sessionsService = sessionsService;
 }
コード例 #26
0
        public async Task ExchangeRequests_ExchangingRequests_ExchangedRequests()
        {
            IMongoDatabase      database           = _mongoFixture.MongoClient.GetDatabase("StudentsDB");
            StudentService      studentSrv         = new StudentService(database);
            BlockChangesService blockChangeService = new BlockChangesService(database);
            var           options             = GetProxyOptions();
            var           schoolScheduleProxy = new SchoolScheduleProxy(options);
            var           schoolCourseProxy   = new SchoolCourseProxy(options);
            CourseService courseService       = new CourseService(_loggerMockCourse.Object, database, schoolScheduleProxy, schoolCourseProxy);

            Course course = await CreateAndAddCourse("Programovanie", "11111", courseService);

            Course course2 = await CreateAndAddCourse("Programovanie", "11111", courseService);


            Block block1 = CreateBlock(BlockType.Laboratory, Day.Monday, 2, 7, course.Id);
            Block block2 = CreateBlock(BlockType.Laboratory, Day.Wednesday, 2, 10, course.Id);
            Block block3 = CreateBlock(BlockType.Laboratory, Day.Tuesday, 2, 15, course.Id);
            Block block4 = CreateBlock(BlockType.Laboratory, Day.Friday, 2, 18, course2.Id);

            Student student1 = new Student();
            Student student2 = new Student();
            Student student3 = new Student();
            await studentSrv.AddAsync(student1);

            await studentSrv.AddAsync(student2);

            await studentSrv.AddAsync(student3);

            BlockChangeRequest blockToChange1 = CreateBlockChangeRequest(block1, block2, student1.Id);
            BlockChangeRequest blockToChange2 = CreateBlockChangeRequest(block1, block3, student1.Id);
            BlockChangeRequest blockToChange3 = CreateBlockChangeRequest(block1, block2, student2.Id);
            BlockChangeRequest blockToChange4 = CreateBlockChangeRequest(block1, block3, student2.Id);
            BlockChangeRequest blockToChange5 = CreateBlockChangeRequest(block4, block2, student3.Id);
            BlockChangeRequest blockToChange  = CreateBlockChangeRequest(block2, block1, student3.Id);
            ValueTuple <BlockChangeRequest, BlockChangeRequest> result = new ValueTuple <BlockChangeRequest, BlockChangeRequest>();

            result = (null, null);
            (await blockChangeService.AddAndFindMatch(blockToChange1)).Should().Equals(result);
            (await blockChangeService.AddAndFindMatch(blockToChange2)).Should().Equals(result);
            (await blockChangeService.AddAndFindMatch(blockToChange3)).Should().Equals(result);
            (await blockChangeService.AddAndFindMatch(blockToChange4)).Should().Equals(result);
            (await blockChangeService.AddAndFindMatch(blockToChange5)).Should().Equals(result);

            result = (blockToChange, blockToChange1);
            (await blockChangeService.AddAndFindMatch(blockToChange)).Should().Equals(result);

            blockChangeService.FindAllStudentRequests(student1.Id).Result.Count.Should().Be(1);
            blockChangeService.FindAllStudentRequests(student2.Id).Result.Count.Should().Be(2);
            blockChangeService.FindAllStudentRequests(student3.Id).Result.Count.Should().Be(2);

            blockChangeService.FindWaitingStudentRequests(student1.Id).Result.Count.Should().Be(0);
            blockChangeService.FindWaitingStudentRequests(student2.Id).Result.Count.Should().Be(2);
            blockChangeService.FindWaitingStudentRequests(student3.Id).Result.Count.Should().Be(1);

            BlockChangeRequest blockToChange6 = CreateBlockChangeRequest(block3, block2, student1.Id);

            (await blockChangeService.AddAndFindMatch(blockToChange6)).Should().Be((null, null));
            blockChangeService.FindWaitingStudentRequests(student1.Id).Result.Count.Should().Be(1);
            blockChangeService.FindWaitingStudentRequests(student2.Id).Result.Count.Should().Be(2);
            blockChangeService.FindWaitingStudentRequests(student3.Id).Result.Count.Should().Be(1);
        }
コード例 #27
0
        public async Task LoadData()
        {
            var service = new CourseService();

            _courses = await service.GetAllCourses();
        }
コード例 #28
0
 public TextToCommandParser(CourseService courseService, Logger logger) : this(courseService)
 {
     _logger = logger;
 }
コード例 #29
0
        /// <summary>
        /// Invokes for libraryView to set avaliable and assigned courses, list of departments and users
        /// </summary>
        /// <param name="companyId">id of selected company, 0 - if not used</param>
        /// <param name="departmentId">id of selected department, 0 if not used</param>
        /// <param name="userId">id of selected user, 0 if not used</param>
        /// <returns></returns>
        public JsonResult FilterCourses(int companyId, int departmentId, int userId)
        {
            LibraryFilter filter = new LibraryFilter();
            //getting avaliable courses
            var listavaliable = new List <MasterCourses>();
            //getting assigned courses
            var listassigned = new List <MasterCourses>();

            if (userId != 0)
            {
                listavaliable = CourseService.MasterCoursesAvaliableTo(userId, FilterIdType.UserId);
                listassigned  = CourseService.MasterCoursesAssignedTo(userId, FilterIdType.UserId);

                filter.assigned = listassigned.Select(item => new CoursesDto
                {
                    CourseId         = item.Id,
                    CoverUrl         = item.CoverUrl,
                    Name             = item.Name,
                    ShortDescription = item.ShortDescription,
                    Time             = item.CourseTime ?? 0,
                    Price            = item.Price ?? 0,
                    Released         = item.Released,
                    Exam             = item.Exam,
                    Exercises        = item.Exercises,
                    Diploma          = item.Diploma,
                    TrailerVideoUrl  = item.TrailerVideoUrl,
                    CourseStatus     = CourseService.GetCourseStatus(userId, FilterIdType.UserId, item.Id),
                    CategoryId       = item.CourseCategoryId,
                    CreatorId        = item.CreatorId,
                    OrderNum         = item.OrderNum
                }).OrderBy(i => i.OrderNum).ToList();
                filter.filterBy = "user";
            }
            else if (departmentId != 0)
            {
                listavaliable = CourseService.MasterCoursesAvaliableTo(departmentId, FilterIdType.DepartmentId);
                listassigned  = CourseService.MasterCoursesAssignedTo(departmentId, FilterIdType.DepartmentId);

                filter.assigned = listassigned.Select(item => new CoursesDto
                {
                    CourseId         = item.Id,
                    CoverUrl         = item.CoverUrl,
                    Name             = item.Name,
                    ShortDescription = item.ShortDescription,
                    Time             = item.CourseTime ?? 0,
                    Price            = item.Price ?? 0,
                    Released         = item.Released,
                    Exam             = item.Exam,
                    Exercises        = item.Exercises,
                    Diploma          = item.Diploma,
                    TrailerVideoUrl  = item.TrailerVideoUrl,
                    CourseStatus     = CourseService.GetCourseStatus(departmentId, FilterIdType.DepartmentId, item.Id),
                    CategoryId       = item.CourseCategoryId,
                    CreatorId        = item.CreatorId,
                    OrderNum         = item.OrderNum
                }).OrderBy(i => i.OrderNum).ToList();

                var dep = CompanyService.GetDepartment(departmentId);
                filter.users = dep.UserProfiles.Select(i => new UserSimple {
                    name = i.Firstname + " " + i.Lastname, id = i.Id
                }).ToList();
                filter.filterBy = "department";
            }
            else if (companyId != 0)
            {
                listavaliable   = CourseService.MasterCoursesAvaliableTo(companyId, FilterIdType.CompanyId);
                listassigned    = CourseService.MasterCoursesAssignedTo(companyId, FilterIdType.CompanyId);
                filter.assigned = listassigned.Select(item => new CoursesDto
                {
                    CourseId         = item.Id,
                    CoverUrl         = item.CoverUrl,
                    Name             = item.Name,
                    ShortDescription = item.ShortDescription,
                    Time             = item.CourseTime ?? 0,
                    Price            = item.Price ?? 0,
                    Released         = item.Released,
                    Exam             = item.Exam,
                    Exercises        = item.Exercises,
                    Diploma          = item.Diploma,
                    TrailerVideoUrl  = item.TrailerVideoUrl,
                    CourseStatus     = CourseService.GetCourseStatus(companyId, FilterIdType.CompanyId, item.Id),
                    CategoryId       = item.CourseCategoryId,
                    CreatorId        = item.CreatorId,
                    OrderNum         = item.OrderNum
                }).OrderBy(i => i.OrderNum).ToList();

                var company = CompanyService.CompanyById(companyId);
                filter.departments = company.Departments.Select(i => new DepartmentSimple {
                    id = i.Id, name = i.DepartmentName
                }).ToList();
                filter.users = company.UserProfiles.Select(i => new UserSimple {
                    name = i.Firstname + " " + i.Lastname, id = i.Id
                }).ToList();
                filter.filterBy = "company";
            }
            else
            {
                listavaliable = CourseService.GetAllMasterCourses();
            }

            filter.aviable = listavaliable.Select(item => new CoursesDto
            {
                CourseId         = item.Id,
                CoverUrl         = item.CoverUrl,
                Name             = item.Name,
                ShortDescription = item.ShortDescription,
                Time             = item.CourseTime ?? 0,
                Price            = item.Price ?? 0,
                Released         = item.Released,
                Exam             = item.Exam,
                Exercises        = item.Exercises,
                Diploma          = item.Diploma,
                TrailerVideoUrl  = item.TrailerVideoUrl,
                CourseStatus     = item.CourseStatus,
                CategoryId       = item.CourseCategoryId,
                CreatorId        = item.CreatorId,
                OrderNum         = item.OrderNum
            }).OrderBy(i => i.OrderNum).ToList();

            return(Json(filter, JsonRequestBehavior.AllowGet));
        }
コード例 #30
0
 public void Setup()
 {
     _courseRepositoryMock = new Mock <ICourseRepository>();
     _service = new CourseService(_courseRepositoryMock.Object);
 }
コード例 #31
0
 public bool BSupdateCourseService(CourseService tservice)
 {
     return(true);
 }
コード例 #32
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult CoursePlan(string id, Guid semId)
        {
            var model = new UserCoursePlanViewModel();
            var user  = UserManager.FindById(id);

            model.User    = user;
            model.Student = Db.Students.Where(x => x.UserId.Equals(user.Id)).OrderByDescending(x => x.Created)
                            .FirstOrDefault();

            var semester = SemesterService.GetSemester(semId);
            var org      = GetMyOrganisation();


            model.Semester = semester;

            var courses =
                Db.Activities.OfType <Course>()
                .Where(c => c.Occurrence.Subscriptions.Any(s => s.UserId.Equals(id)) && c.SemesterGroups.Any((g => g.Semester.Id == semester.Id)))
                .OrderBy(c => c.Name)
                .ToList();

            var courseService = new CourseService(Db);

            foreach (var course in courses)
            {
                var summary = courseService.GetCourseSummary(course);

                var subscriptions = course.Occurrence.Subscriptions.Where(s => s.UserId.Equals(id));
                foreach (var subscription in subscriptions)
                {
                    model.CourseSubscriptions.Add(new UserCourseSubscriptionViewModel
                    {
                        CourseSummary = summary,
                        Subscription  = subscription
                    });
                }

                // jetzt die Tage rausholen und anfügen
                // nur für die mit Platz
                var sub = course.Occurrence.Subscriptions.FirstOrDefault(s => s.UserId.Equals(id));
                if (sub.OnWaitingList == false)
                {
                    foreach (var courseDate in course.Dates)
                    {
                        var dayPlan = model.CourseDates.SingleOrDefault(x => x.Day == courseDate.Begin.Date);
                        if (dayPlan == null)
                        {
                            dayPlan = new UserCourseDatePlanModel {
                                Day = courseDate.Begin.Date
                            };
                            model.CourseDates.Add(dayPlan);
                        }

                        dayPlan.Dates.Add(courseDate);
                    }
                }
            }

            ViewBag.UserRight = GetUserRight();


            return(View(model));
        }
コード例 #33
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FileResult MemberList(string id)
        {
            var organiser = Db.Organisers.SingleOrDefault(org => org.ShortName.ToUpper().Equals(id.ToUpper()));

            var ms     = new MemoryStream();
            var writer = new StreamWriter(ms, Encoding.Default);



            var members = organiser.Members.OrderBy(m => m.Name);


            var semester       = SemesterService.GetSemester(DateTime.Today);
            var vorSemester    = SemesterService.GetPreviousSemester(semester);
            var vorVorSemester = SemesterService.GetPreviousSemester(vorSemester);



            var courseService = new CourseService(Db);


            writer.Write("Kurzname;Name;Rolle;Beschreibung;E-Mail");
            writer.Write(";");
            writer.Write(semester.Name);
            writer.Write(";");
            writer.Write(vorSemester.Name);
            writer.Write(";");
            writer.Write(vorVorSemester.Name);

            writer.Write(Environment.NewLine);


            foreach (var member in members)
            {
                var user = member.UserId != null?UserManager.FindById(member.UserId) : null;

                var eMail = user != null ? user.Email : "Kein Benutzerkonto";


                var active1 = courseService.IsActive(member, semester) ? "Ja" : "Nein";
                var active2 = courseService.IsActive(member, vorSemester) ? "Ja" : "Nein";
                var active3 = courseService.IsActive(member, vorVorSemester) ? "Ja" : "Nein";

                writer.Write("{0};{1};{2};{3};{4};{5};{6}",
                             member.ShortName, member.Name,
                             member.Role,
                             eMail,
                             active1, active2, active3);
                writer.Write(Environment.NewLine);
            }


            writer.Flush();
            writer.Dispose();

            var sb = new StringBuilder();

            sb.Append("Mitglieder_");
            sb.Append(organiser.ShortName);
            sb.Append("_");
            sb.Append(DateTime.Today.ToString("yyyyMMdd"));
            sb.Append(".csv");

            return(File(ms.GetBuffer(), "text/csv", sb.ToString()));
        }
コード例 #34
0
 public SearchController(ApplicationDbContext context, CourseService course, AccessService access)
 {
     _context = context;
     _course  = course;
     _access  = access;
 }
コード例 #35
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SemesterId = SemesterService.GetSemesterId((string)ddlSemester.SelectedValue);
                var level = LevelService.GetLevelId((string)ddlLevel.SelectedValue);
                LevelId = level.Id;

                Student = AspNetUserService.GetStudentId((string)ddlMatricNumber.SelectedValue);
                var data      = (List <ResultSingleStudentTemplateDownloadModel>)gridSingleStudentResult.DataSource;
                var oldResult = ResultService.GetStudentResultForSemester(Student.Id, LevelId, SemesterId);

                var updateResult = false;
                if (oldResult.Count == data.Count)
                {
                    updateResult = true;
                    var dialog = this.ShowMessageBox(@"Student have results for this semester already, Could you like to update it.", "Result Compeletion", MessageBoxButtons.OKCancel, RadMessageIcon.Error);
                    if (dialog == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                if (oldResult.Count < data.Count)
                {
                    var dialog = this.ShowMessageBox($@"Student have {oldResult.Count} results for this semester already, could you like to save the rest.", "Result Processing", MessageBoxButtons.OKCancel, RadMessageIcon.Error);
                    if (dialog == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                var newData = data.Except(oldResult, new ResultSingleStudentTemplateDownloadModelComparer()).ToList();

                var message = string.Empty;
                if (newData.Any())
                {
                    List <ResultModel> resultModels = new List <ResultModel>();
                    foreach (var resultSingleCourseTemplateDownloadModel in newData)
                    {
                        var result = oldResult.FirstOrDefault(c =>
                                                              c.CourseCode.Equals(resultSingleCourseTemplateDownloadModel.CourseCode,
                                                                                  StringComparison.OrdinalIgnoreCase));

                        ResultModel model = null;
                        if (result != null)
                        {
                            if (CheckScore(resultSingleCourseTemplateDownloadModel))
                            {
                                return;
                            }
                            if (updateResult)
                            {
                                model       = ResultService.GetByMatricNumberCourseCode(Student.MatricNumber, result.CourseCode);
                                model.Score = resultSingleCourseTemplateDownloadModel.Score;
                            }

                            if (updateResult)
                            {
                                message +=
                                    $"{resultSingleCourseTemplateDownloadModel.CourseCode}: Old({result.Score}) - New({resultSingleCourseTemplateDownloadModel.Score}){Environment.NewLine}";
                            }
                        }
                        else
                        {
                            if (CheckScore(resultSingleCourseTemplateDownloadModel))
                            {
                                return;
                            }

                            var cId = CourseService.GetCourseByName(resultSingleCourseTemplateDownloadModel.CourseCode).Id;
                            model = new ResultModel
                            {
                                SectionId = level.SectionModels.FirstOrDefault().Id,
                                CourseId  = cId,
                                StudentId = Student.Id,
                                Score     = resultSingleCourseTemplateDownloadModel.Score,
                                CreatedAt = DateTime.UtcNow
                            };

                            message +=
                                $"{resultSingleCourseTemplateDownloadModel.CourseCode}: {resultSingleCourseTemplateDownloadModel.Score}{Environment.NewLine}";
                        }

                        if (model != null)
                        {
                            resultModels.Add(model);
                        }
                    }



                    if (!string.IsNullOrWhiteSpace(message))
                    {
                        var dialogResult = this.ShowMessageBox(message, "Result to process", MessageBoxButtons.OKCancel,
                                                               RadMessageIcon.Info);

                        if (dialogResult == DialogResult.OK)
                        {
                            if (updateResult)
                            {
                                ResultService.UpdateBulk(resultModels);
                            }
                            else
                            {
                                ResultService.CreateBulk(resultModels);
                            }
                            this.ShowMessageBox($"{newData.Count} processed", "Result after processing",
                                                MessageBoxButtons.OKCancel);

                            gridSingleStudentResult.DataSource = ResultService.GetStudentResultForSemester(Student.Id, LevelId, SemesterId);
                        }
                    }

                    return;
                }

                message = "No result to update";
                this.ShowMessageBox(message, "Update Process", MessageBoxButtons.OK, RadMessageIcon.Info);
            }
            catch (Exception ex)
            {
                _logger.Error("Error Message: " + ex.Message, ex);
                this.ShowMessageBox($@"Message: {ex.Message}{Environment.NewLine}Stack Message: {ex.StackTrace}", $@"Error Message from {typeof(AllStudentCourseResult)}");
            }
        }
コード例 #36
0
 public SubscribeController(SubscribeService subscribeService, UsersService usersService, CourseService courseService, SessionsService sessionsService)
 {
     _subscribeService = subscribeService;
     _usersService     = usersService;
     _courseService    = courseService;
     _sessionsService  = sessionsService;
 }
コード例 #37
0
        public void RemoveTest()
        {
            foreach (var v in QualificationsService.GetAllQualifications())
            {
                QualificationsService.RemoveQualification(v);
            }

            foreach (var v in AddressCandidateService.GetAllAddressCandidatePairs())
            {
                AddressCandidateService.Remove(v);
            }

            foreach (var v in AddressService.GetAllAdresses())
            {
                AddressService.RemoveAddress(v);
            }

            foreach (var v in CandidateQualificationService.GetAll())
            {
                CandidateQualificationService.RemoveQualificationFromCandidate(v.CandidateId, v.QualificationId);
            }

            foreach (var v in CandidateService.GetAllCandidates())
            {
                CandidateService.RemoveCandidate(v);
            }

            foreach (var v in CompanyService.GetAllCompanies())
            {
                CompanyService.RemoveCompany(v);
            }

            foreach (var v in CourseService.GetAllCourses())
            {
                CourseService.RemoveCourse(v);
            }

            foreach (var v in JobHistoryCompanyService.GetAll())
            {
                JobHistoryCompanyService.Remove(v.JobHistoryId, v.CompanyId);
            }

            foreach (var v in JobHistoryJobService.GetAll())
            {
                JobHistoryJobService.Remove(v.JobHistoryId, v.JobId);
            }

            foreach (var v in JobHistoryService.GetAllJobHistories())
            {
                JobHistoryService.RemoveJobHistory(v);
            }

            foreach (var v in JobService.GetAllJobs())
            {
                JobService.RemoveJob(v);
            }

            foreach (var v in LocationService.GetAllLocations())
            {
                LocationService.RemoveLocation(v);
            }

            foreach (var v in OpeningService.GetAllOpenings())
            {
                OpeningService.RemoveOpening(v);
            }

            foreach (var v in PlacementService.GetAllPlacements())
            {
                PlacementService.RemovePlacement(v);
            }

            foreach (var v in PrerequisitesForCourseService.GetAll())
            {
                PrerequisitesForCourseService.Remove(v.CourseId, v.QualificationId);
            }

            foreach (var v in QualificationDevelopedByCourseService.GetAll())
            {
                QualificationDevelopedByCourseService.Remove(v.CourseId, v.QualificationId);
            }
        }
コード例 #38
0
 public CoursesController(CourseRepository courseRepository, CourseService courseService)
 {
     this.courseRepository = courseRepository;
     this.courseService = courseService;
 }
コード例 #39
0
        public CreateCourseViewModel(TrainerService trainerService, RoomService roomService, CourseService courseService, AppRegionManager regionManager) : base()
        {
            _roomService    = roomService;
            _trainerService = trainerService;
            _regionManager  = regionManager;
            _courseService  = courseService;

            SetSaveButtonName();
            LoadTrainers();
            LoadRooms();

            StartDate = DateTime.Now;
            EndDate   = DateTime.Now;

            SaveCommand           = new DelegateCommand(Save);
            BackToMainMenuCommand = new DelegateCommand(BackToMainMenu);
        }