Example #1
0
        public async Task <IActionResult> CreateServiceRequest([FromBody] SaveServiceRequestResource serviceRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var request = _mapper.Map <SaveServiceRequestResource, ServiceRequest>(serviceRequest);

            request.PassengerId = await GetUserId();

            request.RequestDate = DateTime.UtcNow;
            _repository.CreateRideRequest(request);
            await _unitOfWork.CompleteAsync();

            var requestResult = _mapper.Map <ServiceRequest, SaveServiceRequestResource>(request);

            return(Ok(requestResult));
        }