Beispiel #1
0
        public async Task <IActionResult> SaveJob([FromBody] SaveJobInputModel inputModel)
        {
            if (ModelState.IsValid)
            {
                var userIP = _httpRequestService.GetIP();
                var user   = await _mediator.Send(UpsertUserByRequestIPCommand.Build(userIP));

                _logger.LogInformation("The user with IP " + userIP + " requested a job.");

                var requestUUID = await _mediator.Send(_mapper.Map <SaveJobInputModel, SaveJobCommand>(inputModel, SaveJobCommand.Build(userIP, user.ID)));

                return(new JsonResult(new {
                    userUUID = user.UUID,
                    requestUUID = requestUUID
                }));
            }
            else
            {
                // TODO: Return detailed error message
                return(BadRequest());
            }
        }