public async Task <LogRequestResponse> PostNewShifts(PostNewShiftsRequest request) { var response = await PostAsync <BaseRequestHelpResponse <LogRequestResponse> >("/api/PostNewShifts", request); if (response.HasContent && response.IsSuccessful) { return(response.Content); } return(null); }
public async Task WhenSuccesfullyReturnsRequestId() { _requestId = 1; _request = new PostNewShiftsRequest() { CreatedByUserId = 1, Location = new SingleLocationRequest() { Location = Location.FranklinHallSpilsby }, OtherDetails = "OTHER DETAILS", ReferringGroupId = -7, Source = "a", ShiftLength = 10, StartDate = DateTime.Now, SupportActivitiesCount = new List <SupportActivityCountRequest>() { new SupportActivityCountRequest() { SupportActivity = SupportActivities.Shopping, Count = 2 }, new SupportActivityCountRequest() { SupportActivity = SupportActivities.CollectingPrescriptions, Count = 5 } } }; _getNewShiftActionsResponse = new GetNewShiftActionsResponse() { TaskActions = new Dictionary <NewTaskAction, List <int> >() { { NewTaskAction.MakeAvailableToGroups, new List <int>() } } }; var response = await _classUnderTest.Handle(_request, new CancellationToken()); _groupService.Verify(x => x.GetRequestHelpFormVariant(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Once); _classUnderTest = new PostNewShiftsHandler(_repository.Object, _groupService.Object, _communicationService.Object); Assert.AreEqual(_requestId, response.RequestID); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] [RequestBodyType(typeof(PostNewShiftsRequest), "post new request for help shift request")] PostNewShiftsRequest req, CancellationToken cancellationToken) { try { _logger.LogInformation("PostNewShifts started"); PostNewShiftsResponse response = await _mediator.Send(req, cancellationToken); return(new OkObjectResult(ResponseWrapper <PostNewShiftsResponse, RequestServiceErrorCode> .CreateSuccessfulResponse(response))); } catch (Exception exc) { _logger.LogErrorAndNotifyNewRelic("Exception occured in PostNewShifts", exc); return(new ObjectResult(ResponseWrapper <PostNewShiftsResponse, RequestServiceErrorCode> .CreateUnsuccessfulResponse(RequestServiceErrorCode.InternalServerError, "Internal Error")) { StatusCode = StatusCodes.Status500InternalServerError }); } }