Пример #1
0
 public async Task <RegisterExam> Save(RegisterExam form)
 {
     //Nếu Form chưa tồn tại với user
     //Tạo mới form
     //Update nếu form đã tồn tại
     if (!await FormValidator.IsExisted(form))
     {
         return(await Create(form));
     }
     return(await Update(form));
 }
Пример #2
0
        public async Task <bool> Delete(RegisterExam form)
        {
            bool IsValid = true;

            IsValid &= await IsExisted(form);

            if (!IsValid)
            {
                form.AddError(nameof(FormValidator), "Form", ErrorCode.NotExisted);
            }
            return(IsValid);
        }
Пример #3
0
        public async Task <bool> Save(RegisterExam form)
        {
            bool IsValid = true;

            IsValid &= await FormApproved(form);

            //IsValid &= await GraduationValidate(form);
            //if (form.Aspirations.Any())
            //{
            //    IsValid &= await SequenceValidate(form.Aspirations);
            //}
            return(IsValid);
        }
Пример #4
0
        public async Task <bool> Create(RegisterExam form)
        {
            RegisterExamDAO formDAO = new RegisterExamDAO
            {
                Id                    = form.Id,
                Graduated             = form.Graduated,
                ClusterContestId      = form.ClusterContestId,
                RegisterPlaceOfExamId = form.RegisterPlaceOfExamId,
                Maths                 = form.Maths,
                Literature            = form.Literature,
                Languages             = form.Languages,
                NaturalSciences       = form.NaturalSciences,
                SocialSciences        = form.SocialSciences,
                Physics               = form.Physics,
                Chemistry             = form.Chemistry,
                Biology               = form.Biology,
                History               = form.History,
                Geography             = form.Geography,
                CivicEducation        = form.CivicEducation,

                ExceptLanguages       = form.ExceptLanguages,
                Mark                  = form.Mark,
                ReserveMaths          = form.ReserveMaths,
                ReserveLiterature     = form.ReserveLiterature,
                ReserveLanguages      = form.ReserveLanguages,
                ReservePhysics        = form.ReservePhysics,
                ReserveChemistry      = form.ReserveChemistry,
                ReserveBiology        = form.ReserveBiology,
                ReserveHistory        = form.ReserveHistory,
                ReserveGeography      = form.ReserveGeography,
                ReserveCivicEducation = form.ReserveCivicEducation,

                PriorityType = form.PriorityType,
                Area         = form.Area,
                Status       = form.Status,
                StudentId    = CurrentContext.StudentId,
            };

            context.RegisterExam.Add(formDAO);
            if (form.Aspirations.Any())
            {
                await BulkCreateAspirations(form);
            }
            await context.SaveChangesAsync();

            return(true);
        }
Пример #5
0
        private async Task <bool> StatusValidation(RegisterExam form)
        {
            //Validate Trạng thái
            //0: Nếu Phiếu ĐKDT chưa được tạo
            //1: Phiếu đang ở trạng thái chờ duyệt => cho phép duyệt
            //2 || 3: Phiếu đã được duyệt, 2 là duyệt nhận, 3 là duyệt từ chối
            if (form.Status == 0 || form.Status == null)
            {
                form.AddError(nameof(FormValidator), "Form", ErrorCode.NotExisted);
            }

            if (form.Status == 2 || form.Status == 3)
            {
                form.AddError(nameof(FormValidator), "Form", ErrorCode.IsApproved);
            }

            return(form.IsValidated);
        }
Пример #6
0
        public async Task <bool> Update(RegisterExam form)
        {
            await context.RegisterExam.Where(f => f.Id == form.Id).UpdateFromQueryAsync(f => new RegisterExamDAO
            {
                Id = f.Id,

                Graduated             = form.Graduated,
                ClusterContestId      = form.ClusterContestId,
                RegisterPlaceOfExamId = form.RegisterPlaceOfExamId,
                Maths           = form.Maths,
                Literature      = form.Literature,
                Languages       = form.Languages,
                Physics         = form.Physics,
                Chemistry       = form.Chemistry,
                Biology         = form.Biology,
                History         = form.History,
                Geography       = form.Geography,
                CivicEducation  = form.CivicEducation,
                NaturalSciences = form.NaturalSciences,
                SocialSciences  = form.SocialSciences,

                Mark                  = form.Mark,
                ExceptLanguages       = form.ExceptLanguages,
                ReserveMaths          = form.ReserveMaths,
                ReserveLiterature     = form.ReserveLiterature,
                ReserveLanguages      = form.ReserveLanguages,
                ReservePhysics        = form.ReservePhysics,
                ReserveChemistry      = form.ReserveChemistry,
                ReserveBiology        = form.ReserveBiology,
                ReserveHistory        = form.ReserveHistory,
                ReserveGeography      = form.ReserveGeography,
                ReserveCivicEducation = form.ReserveCivicEducation,

                Area         = form.Area,
                PriorityType = form.PriorityType,
                Status       = form.Status
            });

            await BulkCreateAspirations(form);

            return(true);
        }
Пример #7
0
        public async Task <bool> BulkCreateAspirations(RegisterExam form)
        {
            await context.Aspiration.Where(d => d.RegisterExamId == form.Id).DeleteFromQueryAsync();

            if (form.Aspirations != null)
            {
                List <AspirationDAO> aspirationDAOs = form.Aspirations.Select(a => new AspirationDAO
                {
                    Id             = a.Id,
                    Sequence       = a.Sequence,
                    RegisterExamId = a.RegisterExamId,
                    MajorsId       = a.MajorsId,
                    UniversityId   = a.UniversityId,
                    SubjectGroupId = a.SubjectGroupId
                }).ToList();
                await context.Aspiration.AddRangeAsync(aspirationDAOs);
            }

            await context.SaveChangesAsync();

            return(true);
        }
Пример #8
0
        public async Task <RegisterExam> Get(long StudentId)
        {
            RegisterExam form = await context.RegisterExam.Where(f => f.StudentId == StudentId).Include(f => f.Aspirations).Select(f => new RegisterExam
            {
                Id        = f.Id,
                StudentId = f.StudentId,

                Graduated               = f.Graduated,
                ClusterContestId        = f.ClusterContestId,
                ClusterContestCode      = f.ClusterContest.Code,
                ClusterContestName      = f.ClusterContest.Name,
                RegisterPlaceOfExamId   = f.RegisterPlaceOfExamId,
                RegisterPlaceOfExamCode = f.RegisterPlaceOfExam.Code,
                RegisterPlaceOfExamName = f.RegisterPlaceOfExam.Name,
                Biology         = f.Biology,
                Chemistry       = f.Chemistry,
                CivicEducation  = f.CivicEducation,
                Geography       = f.Geography,
                History         = f.History,
                Languages       = f.Languages,
                Literature      = f.Literature,
                Maths           = f.Maths,
                NaturalSciences = f.NaturalSciences,
                Physics         = f.Physics,
                SocialSciences  = f.SocialSciences,

                ExceptLanguages       = f.ExceptLanguages,
                Mark                  = f.Mark,
                ReserveBiology        = f.ReserveBiology,
                ReserveChemistry      = f.ReserveChemistry,
                ReserveCivicEducation = f.ReserveCivicEducation,
                ReserveGeography      = f.ReserveGeography,
                ReserveHistory        = f.ReserveHistory,
                ReserveLanguages      = f.ReserveLanguages,
                ReserveLiterature     = f.ReserveLiterature,
                ReserveMaths          = f.ReserveMaths,
                ReservePhysics        = f.ReservePhysics,

                Area         = f.Area,
                PriorityType = f.PriorityType,
                Status       = f.Status,
                Aspirations  = f.Aspirations.Select(a => new Aspiration
                {
                    Id                = a.Id,
                    RegisterExamId    = a.RegisterExamId,
                    MajorsId          = a.MajorsId,
                    MajorsCode        = a.Majors.Code,
                    MajorsName        = a.Majors.Name,
                    UniversityId      = a.UniversityId,
                    UniversityCode    = a.University.Code,
                    UniversityName    = a.University.Name,
                    UniversityAddress = a.University.Address,
                    SubjectGroupId    = a.SubjectGroupId,
                    SubjectGroupCode  = a.SubjectGroup.Code,
                    SubjectGroupName  = a.SubjectGroup.Name,
                    Sequence          = a.Sequence
                }).OrderBy(a => a.Sequence).ToList(),
            }).FirstOrDefaultAsync();

            return(form);
        }
Пример #9
0
        public async Task <RegisterExam> Get(long StudentId)
        {
            RegisterExam form = await UOW.FormRepository.Get(StudentId);

            return(form);
        }