public async Task ShouldGetModelForValidInformation()
        {
            var updateQuestionCategory = new UpdateQuestionCategoryCommand
            {
                Id        = _questionCategoryId,
                TenantId  = _tenantId,
                UpdatedBy = _adminUserId,
                Name      = "questionCategory1",
            };

            var questionCategoryModel = await _updateQuestionCategoryCommandHandler.Handle(updateQuestionCategory, CancellationToken.None);

            Assert.Null(questionCategoryModel.Errors);
        }
        public async Task CanUpdateQuestionCategory()
        {
            var authorizedClient = SystemTestExtension.GetTokenAuthorizeHttpClient(_factory);

            var updateQuestionCategoryCommand = new UpdateQuestionCategoryCommand
            {
                Id   = 1,
                Name = "questionCategory1",
            };

            var serializedUpdateCommand = JsonConvert.SerializeObject(updateQuestionCategoryCommand);

            // The endpoint or route of the controller action.
            var httpResponse = await authorizedClient.PutAsync(requestUri : "/QuestionCategory",
                                                               content : new StringContent(content: serializedUpdateCommand,
                                                                                           encoding: Encoding.UTF8,
                                                                                           mediaType: StringConstants.ApplicationJson));

            //Must be successful
            httpResponse.EnsureSuccessStatusCode();

            Assert.True(httpResponse.IsSuccessStatusCode);
            Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
        }
Пример #3
0
        public async Task <ActionResult <ResponseModel <UpdateQuestionCategoryModel> > > Put([FromBody] UpdateQuestionCategoryCommand command)
        {
            try
            {
                command.UpdatedBy = Claims[ClaimTypes.Sid].ToInt();
                command.TenantId  = Guid.Parse(Claims[ClaimTypes.UserData]);

                var updateQuestionCategoryModel = await Mediator.Send(command);

                return(Ok(updateQuestionCategoryModel));
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
            catch (ObjectAlreadyExistsException ex)
            {
                return(Conflict(new ResponseModel <UpdateQuestionCategoryModel>(new Error(HttpStatusCode.Conflict, ex))));
            }
            catch
            {
                return(StatusCode(HttpStatusCode.InternalServerError.ToInt()));
            }
        }