public async Task ShouldGetModelForValidInformation() { var createWorkingStatusCommand = new CreateWorkingStatusCommand { TenantId = _tenantId, Name = "workingStatusName", CreatedBy = _adminUserId }; var workingStatusModel = await _commandHandler.Handle(createWorkingStatusCommand, CancellationToken.None); Assert.Null(workingStatusModel.Errors); Assert.Equal(expected: createWorkingStatusCommand.Name, actual: workingStatusModel.Items.Single().Name, ignoreCase: true); }
public async Task <ActionResult <ResponseModel <CreateWorkingStatusModel> > > Post([FromBody] CreateWorkingStatusCommand command) { try { command.CreatedBy = Claims[ClaimTypes.Sid].ToInt(); command.TenantId = Guid.Parse(Claims[ClaimTypes.UserData]); var createWorkingStatusModel = await Mediator.Send(command); return(Created($"api/workingStatus/{createWorkingStatusModel.Items.Single().Name}", createWorkingStatusModel)); } catch (NotFoundException) { return(NotFound()); } catch (ObjectAlreadyExistsException ex) { return(Conflict(new ResponseModel <CreateWorkingStatusModel>(new Error(HttpStatusCode.Conflict, ex)))); } catch { return(StatusCode(HttpStatusCode.InternalServerError.ToInt())); } }