示例#1
0
 private IQueryable <UserTest> GetUserTests(int testId, List <int> userIds)
 {
     return(UserTestService.GetAll(x => x.IsBest &&
                                   x.TestModuleSetId.HasValue &&
                                   userIds.Contains(x.UserId) &&
                                   x.TestId == testId));
 }
示例#2
0
        public PublicProfileVM GetPublic(int userID)
        {
            var user = UserService.GetByPK(userID);

            if (user == null)
            {
                return(null);
            }
            var currentUser = AuthService.CurrentUser;
            var tests       = new List <Test>();

            if (!user.HideCourses)
            {
                tests = UserTestService.GetAll(x => x.UserId == userID &&
                                               UserTestStatus.PassStatuses.Contains(x.Status)).OrderByDescending(x => x.RunDate)
                        .Select(x => x.Test).Distinct().ToList();
            }
            var model =
                new PublicProfileVM()
            {
                User          = user,
                IsExcelMaster = IsExcelMaster(user),
                IsOwner       = currentUser != null && currentUser.UserID == userID,
                Socials       = GetSocials(user.UserContacts)
                                .Where(x => !x.Contact.IsEmpty()).ToList(),
                SuccessStory = SuccessStoryService.GetAll()
                               .FirstOrDefault(ss => ss.UserID == user.UserID),
                Tests        = tests,
                Competitions = CompetitionService.GetAll()
                               .Where(c => c.WinnerID == user.UserID).ToList(),
                IsBest = IsBest(user),
            };

            return(model);
        }
示例#3
0
        public ActionResult TestResults()
        {
            UserTestService.LoadWith(x => x.User, x => x.Test);
            var testIds   = _.List(707, 706, 708, 705);
            var userTests = UserTestService.GetAll(x => testIds.Contains(x.TestId)).ToList();
            var data      = UserTestResultService.GetResultData(_.List(userTests));

            return(File(Encoding.GetEncoding(1251).GetBytes(CsvUtil.Render(data)),
                        "text/csv", "TestResults.csv"));
        }
示例#4
0
        public bool IsPreTestPass(OrderDetail od)
        {
            var result = UserTestService.GetAll(x => x.UserId == od.Order.UserID &&
                                                x.Course_TC == od.Course_TC).Select(x => x.Status)
                         .OrderByDescending(x => x).FirstOrDefault();

            if (result == 0)
            {
                return(false);
            }
            return(result > 1);
        }
示例#5
0
        public ActionResult TestCertGroup(TestCertGroupVM model)
        {
            var studentIds = StudentInGroupService.GetAll(x => x.Group_ID == model.GroupId)
                             .Select(x => x.Student_ID).ToList();

            model.UserTests = new List <UserTest>();
            if (model.GroupId > 0)
            {
                var userIds = UserService.GetAll(x => x.Student_ID.HasValue &&
                                                 studentIds.Contains(x.Student_ID.Value)).Select(x => x.UserID).ToList();
                var userTests = UserTestService.GetAll(x => x.TestId == model.TestId &&
                                                       userIds.Contains(x.UserId) && UserTestStatus.PassStatuses.Contains(x.Status)).ToList();
                model.UserTests = userTests;
            }
            model.Tests = TestService.GetAll(x => x.Status == TestStatus.Active).ToList()
                          .OrderBy(x => x.Name).ToList();

            return(View(model));
        }
示例#6
0
        private List <User> GetUsers(List <int> testIds)
        {
            var now   = DateTime.Today;
            var start = new DateTime(now.Year, now.Month, 1).AddMonths(-1);
            var end   = new DateTime(start.Year, start.Month, DateTime.DaysInMonth(start.Year, start.Month));

            var userTests = UserTestService.GetAll(x => x.RunDate >= start &&
                                                   x.RunDate <= end &&
                                                   UserTestStatus.PassStatuses.Contains(x.Status));

            if (testIds.Any())
            {
                userTests = userTests.Where(x => testIds.Contains(x.TestId));
            }
            var bestUserIds = userTests.Where(x => x.User.LastName.ToLower() != "qwe")
                              .Select(x => new { x.UserId, x.TestId }).Distinct().GroupBy(x => x.UserId)
                              .OrderByDescending(x => x.Count()).Select(x => x.Key).Take(10).ToList();

            return(UserService.GetAll(x => bestUserIds.Contains(x.UserID)).ToList());
        }
示例#7
0
        public ActionResult CoursePlanned(string courseTC)
        {
            var course = CourseService.GetByPK(courseTC);
            var testId = course.TestId;

            var moduleSets = TestModuleSetService.GetAll(x => x.TestId == testId)
                             .OrderBy(x => x.Number).ToList();
            var moduleStatuses = UserTestService.GetAll(x =>
                                                        x.IsBest && x.TestId == testId && x.TestModuleSetId.HasValue).ToList()
                                 .GroupBy(x => x.TestModuleSetId.Value)
                                 .ToDictionary(x => x.Key, x => x.First());

            var model = new CoursePlannedTestVM {
                ModuleSets = moduleSets,
                Statuses   = moduleStatuses,
                Course     = course,
            };


            return(BaseViewWithModel(new CoursePlannedTestView(), model));
        }
示例#8
0
 private IQueryable <UserTest> GetUserTests(int testId)
 {
     return(UserTestService.GetAll(x => x.IsBest &&
                                   x.TestModuleSetId.HasValue &&
                                   x.TestId == testId));
 }
示例#9
0
        public ActionResult Recommendations(RecommendationsVM model)
        {
            var courses          = new List <Course>();
            var completeCourseTC = new List <string>();
            var testCourseTC     = new List <string>();

            foreach (var key in ModelState.Keys)
            {
                ModelState[key].Errors.Clear();
            }
            if (System.Web.HttpContext.Current.Request.IsPost())
            {
                var user = UserService.GetAll(x => x.Email == model.Email).FirstOrDefault();
                if (user == null)
                {
                    var student = StudentService.FirstOrDefault(x =>
                                                                x.StudentEmails.Any(z => z.Email == model.Email));
                    if (student != null)
                    {
                        user = new User {
                            Student = student
                        }
                    }
                    ;
                }
                if (user == null)
                {
                    this.ModelState.AddModelError("", "Слушатель не существует");
                }
                else
                {
                    if ((model.ProductId == 0 && model.ProfessionId == 0) ||
                        (model.ProductId > 0 && model.ProfessionId > 0))
                    {
                        this.ModelState.AddModelError("", "Выберите профессию или продукт");
                    }
                    else
                    {
                        var entityCourseTCList = EntityStudySetService.GetByPK(
                            Math.Max(model.ProductId, model.ProfessionId)).CourseTCList;
                        completeCourseTC = GetCompleteCourses(user);

                        courses = GetCourses(entityCourseTCList, completeCourseTC);
                        if (user.UserID > 0)
                        {
                            var testIds = UserTestService.GetAll(x => x.UserId == user.UserID &&
                                                                 UserTestStatus.PassStatuses.Contains(x.Status))
                                          .Select(x => x.TestId).Distinct().ToList();
                            testCourseTC = SiteObjectRelationService.GetRelation(typeof(Test),
                                                                                 testIds.Cast <object>(), typeof(Course))
                                           .Select(x => x.RelationObject_ID).ToList().Cast <string>()
                                           .ToList();
                        }
                    }
                }
            }
            else
            {
                model = new RecommendationsVM();
            }
            var sets = EntityStudySetService.GetAll().ToList();

            model.Professions       = sets.Where(x => x.Type == 1).OrderBy(x => x.EntityName).ToList();
            model.Products          = sets.Where(x => x.Type == 2).OrderBy(x => x.EntityName).ToList();
            model.Courses           = courses;
            model.TestCourseTCs     = testCourseTC;
            model.CompleteCourseTCs = completeCourseTC;
            return(View(model));
        }