Beispiel #1
0
        public TestBankVMResponse GetLocalExamInfo(string centerid)
        {
            var sheet     = shareRepo.GetAvailableExamSheet(centerid);
            var testRegis = onsiteRepo.ListTestRegis(centerid);

            var group = from item in sheet
                        group item by new
            {
                item.Subject.SubjectCode,
                item.Subject.SubjectName,
                item.Subject.ContentLanguage,
                item.Subject.Version,

                //iten.Subject.Voices, TODO : Groupby Voice
            } into gitem
            let qty = gitem.Count()
                      let book = testRegis.Where(x => x.SubjectCode == gitem.Key.SubjectCode && x.ExamLanguage == gitem.Key.ContentLanguage).Count()
                                 select new ExamSheetOnSiteRespone
            {
                SubjectCode   = gitem.Key.SubjectCode,
                SubjectName   = gitem.Key.SubjectName,
                ExamLanguage  = gitem.Key.ContentLanguage,
                Version       = gitem.Key.Version,
                Quantity      = qty,
                Book          = book,
                VoiceLanguage = "th",             //TODO : Groupby Voice
                IsExamEnough  = qty >= book
            };

            var result = new TestBankVMResponse
            {
                ExamSheets = group.ToList(),
            };

            return(result);
        }
Beispiel #2
0
        public DisplayAllVM ListTestRegistration(string centerid)
        {
            var fromtestRegis = repoOnSite.ListTestRegis(centerid);

            if (fromtestRegis.Count() > 0)
            {
                var mappedsheet = repoOnSite.GetMappedSheet(centerid);

                var fromtestRegisExistMappedsheet = fromtestRegis.Where(p2 => mappedsheet.All(p1 => p1.TestRegisID != p2._id));

                var _listTestRegisBySheet = repoOnSite.GetTestRegisByIds(mappedsheet.Select(x => x.TestRegisID).ToList());

                List <TestRegistrationRespone> formsheet = new List <TestRegistrationRespone>();

                foreach (var item in mappedsheet)
                {
                    var regis = _listTestRegisBySheet.Where(x => x._id == item.TestRegisID).FirstOrDefault();

                    if (regis != null)
                    {
                        var sheetRegis = new TestRegistrationRespone()
                        {
                            _id           = regis._id,
                            Title         = regis.Title,
                            FirstName     = regis.FirstName,
                            LastName      = regis.LastName,
                            SubjectCode   = regis.SubjectCode,
                            SubjectName   = regis.SubjectName,
                            ExamLanguage  = regis.ExamLanguage,
                            VoiceLanguage = regis.VoiceLanguage,
                            RegDate       = regis.RegDate,
                            RegDateString = regis.RegDateString,
                            ExpriedDate   = regis.ExpriedDate,
                            SiteId        = regis.SiteId,
                            CenterId      = regis.CenterId,
                            ForPractice   = regis.ForPractice,
                            ForTestSystem = regis.ForTestSystem,
                            Status        = item.LatestStatus,
                            PID           = regis.PID,
                            ExamNumber    = regis.ExamNumber,
                            ExamPeriod    = regis.ExamPeriod,
                            AppointDate   = regis.AppointDate,
                            Address       = regis.Address,
                            MaxCount      = regis.MaxCount,
                            LatestCount   = item.TestCount,
                            CertData      = new CertData
                            {
                                CertNo   = regis.CertData.CertNo,
                                CertYear = regis.CertData.CertYear,
                                UserCode = regis.CertData.UserCode
                            },
                            IsSync        = item.IsSync,
                            SheetId       = item._id,
                            CorrectCount  = item.CorrectScore,
                            QuestionCount = item.RandomQuestions.Count(),
                        };

                        formsheet.Add(sheetRegis);
                    }
                }

                var result = new DisplayAllVM
                {
                    TestRegistrations = fromtestRegisExistMappedsheet.Select(x => new TestRegistrationRespone
                    {
                        _id           = x._id,
                        Title         = x.Title,
                        FirstName     = x.FirstName,
                        LastName      = x.LastName,
                        SubjectCode   = x.SubjectCode,
                        SubjectName   = x.SubjectName,
                        ExamLanguage  = x.ExamLanguage,
                        VoiceLanguage = x.VoiceLanguage,
                        RegDate       = x.RegDate,
                        RegDateString = x.RegDateString,
                        ExpriedDate   = x.ExpriedDate,
                        SiteId        = x.SiteId,
                        CenterId      = x.CenterId,
                        ForPractice   = x.ForPractice,
                        ForTestSystem = x.ForTestSystem,
                        Status        = x.Status,
                        PID           = x.PID,
                        ExamNumber    = x.ExamNumber,
                        ExamPeriod    = x.ExamPeriod,
                        AppointDate   = x.AppointDate,
                        Address       = x.Address,
                        MaxCount      = x.MaxCount,
                        CertData      = new CertData
                        {
                            CertNo   = x.CertData.CertNo,
                            CertYear = x.CertData.CertYear,
                            UserCode = x.CertData.UserCode
                        },
                        LatestCount   = x.LatestCount <= 1 ? 1 : x.LatestCount,
                        IsSync        = x.IsSync,
                        SheetId       = string.Empty,
                        CorrectCount  = 0,
                        QuestionCount = 0,
                    }).ToList(),
                };
                result.TestRegistrations.AddRange(formsheet);

                return(result);
            }
            else
            {
                return(new DisplayAllVM {
                    TestRegistrations = new List <ViewModels.TestRegistrationRespone>()
                });
            }
        }