public IActionResult UpdateRequest(int id, [FromBody] MemberReqUpdateDto updateRequest)
        {
            var requestEntity = _transActionRepo.GetRequest(id);

            if (requestEntity == null)
            {
                return(NotFound());
            }
            if (updateRequest == null)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            _mapper.Map(updateRequest, requestEntity);


            if (!_transActionRepo.Save())
            {
                return(StatusCode(500, "A problem happened while handling your request."));
            }

            return(NoContent());
        }
Exemplo n.º 2
0
        public IActionResult UpdateRequest(int id, [FromBody] MemberReqUpdateDto updateRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new TransActionResponse(ModelState)));
            }
            var requestEntity = _unitOfWork.Request.GetReqById(id);

            if (requestEntity == null)
            {
                return(StatusCode(404, new TransActionResponse("Request Not Found")));
            }

            _mapper.Map(updateRequest, requestEntity);
            _unitOfWork.Request.Update(requestEntity);

            if (!_unitOfWork.Save())
            {
                return(StatusCode(500, new TransActionResponse("A problem happened while handling your request.")));
            }

            return(StatusCode(StatusCodes.Status204NoContent, new TransActionResponse()));
        }