Ejemplo n.º 1
0
            public Task <int> Handle(RegisterUserRequest request, CancellationToken cancellationToken)
            {
                var model = request.Model;

                var user = new User
                {
                    Name              = model.Name,
                    Email             = model.Email,
                    EncryptedPassword = PasswordEncrypter.EncryptPassword(model.Password)
                };

                return(Task.FromResult(AddEntityCommand.Execute(user)));
            }
            public Task <int> Handle(AddResponseRequest request, CancellationToken cancellationToken)
            {
                var currentUserSid = HttpContextAccessor.HttpContext.User.Claims.Single(c => c.Type == JwtRegisteredClaimNames.Sid).Value;
                var model          = new AddResponseModel
                {
                    QuestionnaireId   = request.RequestModel.QuestionnaireId,
                    CompletedByUserId = int.Parse(currentUserSid)
                };

                var user          = GetEntityByIdQuery.Execute <User>(model.CompletedByUserId);
                var questionnaire = GetEntityByIdQuery.Execute <Questionnaire>(model.QuestionnaireId);

                var response = new Response {
                    CompletedByUser = user, Questionnaire = questionnaire
                };

                AddEntityCommand.Execute(response);

                CreateAnswers(ref response, questionnaire.Id);

                return(Task.FromResult(response.Id));
            }
Ejemplo n.º 3
0
            public Task <int> Handle(AddQuestionnaireRequest request, CancellationToken cancellationToken)
            {
                var model         = request.Model;
                var createdByUser = GetEntityByIdQuery.Execute <User>(model.CreatedByUserId);

                var questionnaire = new Questionnaire
                {
                    Name          = model.Name,
                    CreatedDate   = TimeProvider.GetDateTimeNow(),
                    CreatedByUser = createdByUser
                };

                return(Task.FromResult(AddEntityCommand.Execute(questionnaire)));
            }
Ejemplo n.º 4
0
            public Task <int> Handle(AddSectionRequest request, CancellationToken cancellationToken)
            {
                var model         = request.Model;
                var questionnaire = GetEntityByIdQuery.Execute <Questionnaire>(model.QuestionnaireId);

                var section = new Section
                {
                    Name          = model.Name,
                    Ordinal       = model.Ordinal,
                    Questionnaire = questionnaire
                };

                return(Task.FromResult(AddEntityCommand.Execute(section)));
            }
            public Task <int> Handle(AddQuestionRequest request, CancellationToken cancellationToken)
            {
                var model         = request.Model;
                var questionnaire = GetEntityByIdQuery.Execute <Questionnaire>(model.QuestionnaireId);
                var section       = GetEntityByIdQuery.Execute <Section>(model.SectionId);

                var question = new Question
                {
                    Text          = model.Text,
                    Ordinal       = model.Ordinal,
                    Questionnaire = questionnaire,
                    Section       = section
                };

                return(Task.FromResult(AddEntityCommand.Execute(question)));
            }