public async Task <ActionResult> SaveProjectTask(SaveProjectTaskViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var request  = Mapper.Map <SaveProjectTaskViewModel, SaveProjectTaskRequest>(model);
            var response = await Mediator.Send(request);

            if (ResponseHelper.IsSuccessful(response))
            {
                return(Ok(response.Result));
            }

            return(BadRequest(response.Errors));
        }
예제 #2
0
        public async Task SaveProjectTask_when_successful_returns_Status200()
        {
            var model             = new SaveProjectTaskViewModel();
            var request           = new SaveProjectTaskRequest();
            var cancellationToken = CancellationToken.None;

            mapper.Setup(m => m.Map <SaveProjectTaskViewModel, SaveProjectTaskRequest>(model))
            .Returns(request).Verifiable();

            mediator.Setup(m => m.Send(request, cancellationToken))
            .Returns(Task.FromResult(new SaveProjectTaskResponse {
            })).Verifiable();

            var result = await projectTaskController.SaveProjectTask(model);

            mapper.VerifyAll();
            mediator.VerifyAll();
        }