Exemplo n.º 1
0
        public GroupUserTests Create(GroupTest groupTest, List <int> userIds, UserTestService userTestService)
        {
            var userTests = userTestService.GetUserTests(groupTest).Where(x => userIds.Contains(x.UserId)).ToList();
            var best      =
                userTests.GroupBy(x => x.UserId).Select(x => x.OrderByDescending(y => y.Status).FirstOrDefault())
                .ToList();

            return(new GroupUserTests {
                GroupTest = groupTest, UserTests = best
            });
        }
Exemplo n.º 2
0
        public ActionResult DownloadResult(int groupInfoId)
        {
            List <int> userIds;
            var        groupInfo = GetGroupInfo(groupInfoId, out userIds);

            UserTestService.LoadWith(x => x.User, x => x.Test);
            var userTests = groupInfo.GroupTests.Select(gt => UserTestService.GetUserTests(gt)
                                                        .Where(x => userIds.Contains(x.UserId)).ToList()).ToList();
            var data = UserTestResultService.GetResultData(userTests);

            return(File(Encoding.GetEncoding(1251).GetBytes(CsvUtil.Render(data)),
                        "text/csv", "GroupResults-{0}.csv".FormatWith(groupInfo.Group_ID)));
        }