public async Task ShouldThrowErrorWhenInvalidInformation() { var updateWorkingStatusCommand = new UpdateWorkingStatusCommand { Id = _workingStatusId + 1, Name = "testWorkingStatusUpdate", TenantId = _tenantId, UpdatedBy = _adminUserId }; await Assert.ThrowsAsync <NotFoundException>(async() => await _commandHandler.Handle(updateWorkingStatusCommand, CancellationToken.None)); }
public async Task ShouldGetModelForValidInformation() { var updateWorkingStatusCommand = new UpdateWorkingStatusCommand { Id = _workingStatusId, Name = "testWorkingStatusUpdate", TenantId = _tenantId, UpdatedBy = _adminUserId }; var workingStatusModel = await _commandHandler.Handle(updateWorkingStatusCommand, CancellationToken.None); Assert.Null(workingStatusModel.Errors); Assert.Equal(expected: updateWorkingStatusCommand.Name, actual: workingStatusModel.Items.Single().Name, ignoreCase: true); }
public async Task <ActionResult <ResponseModel <UpdateWorkingStatusModel> > > Put([FromBody] UpdateWorkingStatusCommand command) { try { command.UpdatedBy = Claims[ClaimTypes.Sid].ToInt(); command.TenantId = Guid.Parse(Claims[ClaimTypes.UserData]); var updateWorkingStatusModel = await Mediator.Send(command); return(Ok(updateWorkingStatusModel)); } catch (NotFoundException) { return(NotFound()); } catch (ObjectAlreadyExistsException ex) { return(Conflict(new ResponseModel <UpdateWorkingStatusModel>(new Error(HttpStatusCode.Conflict, ex)))); } catch { return(StatusCode(HttpStatusCode.InternalServerError.ToInt())); } }