Example #1
0
        public async Task <ActionResult> PostRequest(RequestCreateDto requestCreate)
        {
            try
            {
                var mappedmodel = mapper.Map <Request>(requestCreate);
                await requestsRepository.CreateRequestAsync(mappedmodel);

                await requestsRepository.SaveAsync();

                var createdReadModel = mapper.Map <RequestReadDto>(mappedmodel);
                return(CreatedAtRoute(nameof(GetRequestById), new { createdReadModel.Id }, createdReadModel));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new Response {
                    Status = "Error", Message = ex.Message
                }));
            }
        }