예제 #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);
        }
예제 #2
0
 protected virtual Content GetThesisContent(ThesisCertification thesis)
 {
     return(new Content(
                new FieldContent("PreliminaryResult", thesis?.PreliminaryResult.ValueOrDefault()),
                new FieldContent("ProtocolDate", thesis?.Protocol?.Date?.ToShortDateString() ?? ""),
                new FieldContent("ProtocolNumber", thesis?.Protocol?.Number?.ToString() ?? ""),
                new FieldContent("Mark", thesis?.Mark != null && thesis.Mark == 0 ? "" : thesis?.Mark.ToString()),
                new FieldContent("IsApprovedCertification", thesis.IsApproved ? "защищена" : "не защищена")
                ));
 }