Example #1
0
        public async Task <IActionResult> UpdateServiceRequestForApprove(int id)
        {
            var result = await _repository.GetServiceRequestDetails(id);

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

            if (_repository.IsServiceProviderAlreadyOnRide(result.Service.ServiceProviderId))
            {
                return(BadRequest("Service Provider is already on ride. At this moment this service provider can not approve ride request"));
            }

            result.IsPending  = false;
            result.IsApproved = true;

            await _unitOfWork.CompleteAsync();

            //Start Sending notification after approve a Service request

            var approvedNotification = new NotificationInformation();

            approvedNotification.DeviceInformations = await _userDeviceInfoRepository.GetUserDeviceInformationsAsync(result.ApplicationUser.Id);

            approvedNotification.NotiTitle   = "Knarr";
            approvedNotification.NotiMessage = "Ride Request Approved";

            await _fireBaseServiceClient.SendNotification(approvedNotification);

            //End Sending notification after approve a Service request
            return(Ok(result));
        }