Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateRideRequestForDelete(int id)
        {
            var result = await _repository.GetServiceRequestDetails(id);

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

            if (result.OnRide)
            {
                return(BadRequest("Ride already started"));
            }

            result.IsPending   = false;
            result.IsDeleted   = true;
            result.DeletedDate = DateTime.UtcNow;

            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 Canceled";

            await _fireBaseServiceClient.SendNotification(approvedNotification);

            //End Sending notification after approve a Service request

            return(Ok(id));
        }
Exemplo n.º 3
0
        public async void MessageError(String Message)
        {
            NotificationInformation msg = new NotificationInformation();

            msg.Message = Message;
            msg.Icon    = "Exclamation";
            await DialogHost.Show(msg, "RootDialog");
        }
Exemplo n.º 4
0
        private async void caixaDialogo(String Message, String Icon)
        {
            NotificationInformation box = new NotificationInformation();

            box.Message = Message;
            box.Icon    = Icon;
            await DialogHost.Show(box, "dialogUpdate");
        }
Exemplo n.º 5
0
        public async void caixaMensagem(String message)
        {
            NotificationInformation msg = new NotificationInformation();

            msg.Message = message;
            await DialogHost.Show(msg, "DialogNormal");

            txtUsuario.Text       = "";
            txtSenha.Password     = "";
            txtConfSenha.Password = "";
        }
Exemplo n.º 6
0
        public async Task <bool> SendNotification(NotificationInformation information)
        {
            foreach (var details in information.DeviceInformations)
            {
                if (string.IsNullOrWhiteSpace(details.FcmToken))
                {
                    var fireUri     = new Uri("https://fcm.googleapis.com/fcm/send");
                    var fireRequest = WebRequest.Create(fireUri);
                    fireRequest.Method = "POST";
                    fireRequest.Headers.Add("Authorization", $"key={ServerKey}");
                    fireRequest.Headers.Add("Sender", $"id={SenderId}");
                    fireRequest.ContentType = "application/json";

                    var payLoad = new
                    {
                        to                = "dsfsdfsdfsd",//details.FcmToken,
                        priority          = "high",
                        content_available = true,
                        notification      = new
                        {
                            title = information.NotiTitle,
                            body  = information.NotiMessage
                        },
                    };
                    var data = JsonConvert.SerializeObject(payLoad);

                    var byteArray = Encoding.UTF8.GetBytes(data);
                    fireRequest.ContentLength = byteArray.Length;
                    using (var dataStream = fireRequest.GetRequestStream())
                    {
                        dataStream.Write(byteArray, 0, byteArray.Length);
                        using (var fireResponse = await fireRequest.GetResponseAsync())
                        {
                            using (var dataStreamResponse = fireResponse.GetResponseStream())
                            {
                                if (dataStreamResponse != null)
                                {
                                    using (var fireReader = new StreamReader(dataStreamResponse))
                                    {
                                        var sResponseFromServer = fireReader.ReadToEnd();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
Exemplo n.º 7
0
        public async void BemVindo()
        {
            NotificationInformation msg = new NotificationInformation();

            msg.Message = "Bem vindo!";
            msg.Icon    = "Login";

            await DialogHost.Show(msg, "RootDialog");

            MainWindow w      = this;
            WindowMain window = new WindowMain();

            w.Close();
            window.Show();
        }