Ejemplo n.º 1
0
        private async void NavigateNotification(NotificationsTypesEnum NotificationType, int NotificationID)
        {
            if (NotificationType == NotificationsTypesEnum.Chat)
            {
                //TODO
            }
            else if (NotificationType == NotificationsTypesEnum.Cooker)
            {
                OrdersModel     model  = new OrdersModel();
                CookerViewModel cooker = await model.GetCooker(NotificationID);

                await PageTemplate.CurrentPage.NavigateAsync(new SingleCookerPage(cooker) { Title = cooker.Name });
            }
            else if (NotificationType == NotificationsTypesEnum.Recipe)
            {
                RecipesModel    model  = new RecipesModel();
                RecipeViewModel recipe = await model.GetRecipeFromID(NotificationID);

                await PageTemplate.CurrentPage.NavigateAsync(new SingleRecipePage(recipe) { Title = recipe.Title });
            }
            else
            {
                await PageTemplate.CurrentPage.NavigateAsync(Utility.PageParser(PageNavigateEnums.NotificationsPage));
            }
        }
Ejemplo n.º 2
0
        protected override void OnResume()
        {
            base.OnResume();
            if (Intent?.Extras != null)
            {
                try
                {
                    string data = Intent?.Extras.GetString("data");
                    if (data != null)
                    {
                        Intent.RemoveExtra("data");

                        NotificationDTO notification         = JsonConvert.DeserializeObject <NotificationDTO>(data);
                        string          NotificationSentTime = Intent.Extras.GetString("NotificationSentTime");
                        notification.NotificationSentTime = DateTime.Parse(NotificationSentTime);

                        if (!DataBase.Instance.Query <NotificationDTO>().Any(x => x.NotificationID == notification.NotificationID))
                        {
                            if (notification.NotificationType == NotificationsTypesEnum.Order)
                            {
                                notification.IsOrderPending = true;
                            }

                            DataBase.Instance.Add(notification);
                        }

                        NavigateNotification(notification.NotificationType, notification.NotificationID);
                    }
                    else
                    {
                        string NotificationID = Intent.Extras.GetString("notificationID");
                        NotificationsTypesEnum NotificationType = (NotificationsTypesEnum)Enum.Parse(typeof(NotificationsTypesEnum), Intent.Extras.GetString("notificationType"), true);
                        if (!string.IsNullOrEmpty(NotificationID))
                        {
                            if (DataBase.Instance.Query <NotificationDTO>().FirstOrDefault(x => x.NotificationID == int.Parse(NotificationID)) != null)
                            {
                                string NotificationSentTime = Intent.Extras.GetString("notificationSentTime");
                                string NotificationTitle    = Intent.Extras.GetString("notificationTitle");
                                string NotificationBody     = Intent.Extras.GetString("notificationBody");

                                DataBase.Instance.Add(new NotificationDTO()
                                {
                                    NotificationID       = int.Parse(NotificationID),
                                    NotificationBody     = NotificationBody,
                                    NotificationSentTime = DateTime.Parse(NotificationSentTime),
                                    NotificationTitle    = Title,
                                    NotificationType     = NotificationType,
                                    IsOrderPending       = NotificationType == NotificationsTypesEnum.Order ? true : false
                                });
                            }
                        }
                        NavigateNotification(NotificationType, int.Parse(NotificationID));
                    }
                }
                catch (Exception)
                {
                    //Exception ?
                }
            }
        }