Example #1
0
        public AuthResponse RegisterUndergraduate(UndergraduateRegisterVM undergraduate)
        {
            var dbUser  = this._repository.Users.FindByLoginPassword(undergraduate.User.Login.Login, undergraduate.User.Login.Password);
            var context = new AuthResponse();

            if (dbUser == null)
            {
                var entity = this._mapper.Map <Undergraduate>(undergraduate);

                var thesisData = new ThesisCertification()
                {
                    Protocol = new Protocol()
                };
                var journal = new UndergraduateJournal()
                {
                    ThesisCertification = thesisData
                };

                entity.Journals.Add(journal);
                entity.User.RoleId = this.GetOrAddRole(RoleNames.Undergraduate);

                this._repository.Undergraduates.Add(entity);
                this._repository.Save();

                context.User                 = this._mapper.Map <UserContext>(entity.User);
                context.User.Role            = RoleNames.Undergraduate;
                context.User.SpecifiedUserId = entity.UndergraduateId;

                return(context);
            }

            context.Alert = Config.LoginExist;
            return(context);
        }
Example #2
0
        public byte[] Convert(UndergraduateJournal journal)
        {
            string templatePath = this.GetInputTemplatePath();
            string outputPath   = this.GetOutputTemplatePath(journal.UndergraduateId ?? 0);

            if (File.Exists(outputPath))
            {
                File.Delete(outputPath);
            }

            File.Copy(templatePath, outputPath);

            TableContent  researchWorksContent = this.GetResearchesContent(journal.PreparationInfo.ResearchWorks);
            RepeatContent reportsContent       = this.GetReportsFields(journal.ReportResults, journal.Undergraduate.Specialty?.Department?.Head);

            Content preparationInfoContent     = this.GetPreparationInfoContent(journal.PreparationInfo);
            Content thesisCertificationContent = this.GetThesisContent(journal.ThesisCertification);
            Content universityContent          = this.GetUniversityContent(journal.Undergraduate.Specialty);

            Content ujContent = this.GetUJContent(journal.Undergraduate);

            ujContent.Repeats.Add(reportsContent);
            ujContent.Tables.Add(researchWorksContent);

            using (var outputDoc = new TemplateProcessor(outputPath).SetRemoveContentControls(true))
            {
                outputDoc.FillContent(ujContent);

                outputDoc.FillContent(universityContent);
                outputDoc.FillContent(preparationInfoContent);
                outputDoc.FillContent(thesisCertificationContent);
                outputDoc.SaveChanges();
            }

            return(File.ReadAllBytes(outputPath));
        }