public async Task Add_ReturnBadRequest_WhenTaskHasNotBeenSuccessfully() { //Arrange var addTaskInput = new AddTaskInput { Title = "Ma tâche" }; _handleAzureBatch.Setup(mes => mes.ExecuteAsync(It.IsAny <StorageTask>())).ReturnsAsync(new Result { Status = Status.Success }); _addTaskMock.Setup(mes => mes.ExecuteAsync(It.IsAny <StorageTask>())).ReturnsAsync(new Result { Status = Status.Fail }); //Act var actionResult = await _tasksController.Post(addTaskInput) as BadRequestObjectResult; //Assert _handleAzureBatch.Verify(mes => mes.ExecuteAsync(It.IsAny <StorageTask>()), Times.Once); _addTaskMock.Verify(mes => mes.ExecuteAsync(It.IsAny <StorageTask>()), Times.Once); Assert.NotNull(actionResult); Assert.IsType <string>(actionResult.Value); Assert.Equal("Task cannot be added", actionResult.Value); }
public async System.Threading.Tasks.Task <IActionResult> AddTask(AddTaskInput input) { Result <string> result = await _taskManager.AddTask(input); if (result.Success) { return(Ok(result)); } else { return(BadRequest(result)); } }
public async Task <IActionResult> AddTask( [FromServices] IMediator mediator, [FromServices] AddTaskPresenter presenter, [FromBody][Required] AddTaskRequest request) { var accountId = this.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "AccountId").Value; var input = new AddTaskInput( new BaseEntityId(new Guid(accountId)), new BaseEntityId(request.TableId), new TaskText(request.Title)); await mediator.PublishAsync(input); return(presenter.ViewModel); }
public async System.Threading.Tasks.Task <Result <string> > AddTask(AddTaskInput input) { Task task = new Task() { Date = input.Date, Time = input.Time, EventType = input.EventType, Location = input.Location, Note = input.Note, PhotographId = input.PhotographId }; return(new Result <string>() { Success = true, Data = await _taskRepository.CreateAsync(task) }); }
public async Task <IActionResult> Post([FromBody] AddTaskInput addTaskInput) { var task = new StorageTask { Id = Guid.NewGuid(), Title = addTaskInput.Title, IsSuccess = addTaskInput.IsSuccess, Services = addTaskInput.Services }; //var resultHandle = await _handleAzureBatch.ExecuteAsync(task); var result = await _addTask.ExecuteAsync(task); var resultCreateInstance = _createContainerInstance.Execute(task); if (result.Status == Status.Success && resultCreateInstance.Status == Status.Success) { return(Ok("Task has been successfully added")); } return(BadRequest("Task cannot be added")); }
public async Task Handle(AddTaskInput input) { if (input is null) { outputPort.WriteError(Message.InputIsNull); return; } try { var table = await tableRepository.GetTableAsync(input.TableId, input.AccountId); var task = await tableService.AddTask(table, input.TaskText); await unitOfWork.Save(); BuildOutput(task); } catch (Exception e) { outputPort.WriteError(e.Message); } }