public async Task <IHttpActionResult> CreateHelpRequestResponse(/*[FromBody]*/ HelpRequestResponseCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Content(HttpStatusCode.BadRequest, GetValidationErrors()));
            }

            var helpRequest = _helpRequestService.GetById(model.HelpRequestId);

            if (helpRequest == null)
            {
                return(NotFound());
            }

            var helpRequestResponse = _helpRequestResponseService.CreateClientHelpRequestResponse(model);

            if (helpRequestResponse == null)
            {
                return(InternalServerError());
            }

            var client = await _clientService.FindById(helpRequest.ClientId);

            var result = MapHelpRequestResponse(helpRequestResponse, client.ClientId);

            bool isSuccess = await _notificationService.SendHelpRequestNotification(client.ClientId, result);

            if (isSuccess)
            {
                return(Ok());
            }
            return(InternalServerError());
        }
Exemplo n.º 2
0
        public IHttpActionResult Get(int helpRequestId)
        {
            var result = _helpRequestService.GetById(helpRequestId);

            return(Ok(result));
        }