public async Task <bool> DeleteQuote(DesignQuote designQuote) { var sql = $"delete from {nameof(DesignQuote)} where id = ?"; try { return(await database.ExecuteAsync(sql, designQuote.Id) == 1); } catch (Exception ex) { throw ex; } }
public static void ShareQuote(Context context, DesignQuote designQuote, bool isLongQuote) { string text = GetImageText(designQuote); if (isLongQuote) { ShareText(context, text); } else { Bitmap bitmap = GetBitmap(context, text, designQuote.Color.PrimaryColor, designQuote.Color.SecondaryColor); ShareImage(context, bitmap); } }
public async Task AddQuote(DesignQuote quote, bool isAnonymous, string deviceId = null) { var author = isAnonymous || string.IsNullOrWhiteSpace(quote.Author) ? null : quote.Author; var response = await httpClient.Post("/api/v1/quotes", new { color = quote.Color.Id, quote = quote.Quote, author, device_id = deviceId }); if (!response.IsSuccessStatusCode) { var content = await response.Content.ReadAsStringAsync(); throw new Exception(content); } }
public async Task <bool> FlagQuote(DesignQuote quote, int flagReasonId) { try { var response = await httpClient.Post($"/api/v1/quotes/{quote.Id}/flag", new { flag_reason = flagReasonId }); if (!response.IsSuccessStatusCode) { var responseMessae = await response.Content.ReadAsStringAsync(); Utils.LogError(new Exception(responseMessae), "ErrorFlaggingQuote"); } return(response.IsSuccessStatusCode); } catch (Exception ex) { Utils.LogError(ex, "ErrorFlagingQuote"); return(false); } }
public override async void OnReceive(Context context, Intent intent) { switch (intent.Action) { case Constants.SHARE_NOTIFICATION_QUOTE_INTENT_ACTION: { try { DesignQuote designQuote = JsonConvert.DeserializeObject <DesignQuote>(intent.GetStringExtra(Constants.SHARE_NOTIFICATION_QUOTE_INTENT_ACTION)); // Close Notification Drawer context.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); Helper.ShareQuote(context, designQuote, designQuote.Quote.Length > Helpers.Constants.MAX_QUOTE_LENGTH); var notificationManager = NotificationManagerCompat.From(context); // Get notificationID which is the current count - 1 var notificationId = Settings.NotificationCount - 1; notificationManager.Cancel(notificationId); } catch (Exception ex) { Utils.LogError(ex, "SharingQuote"); } } break; case Constants.NOTIFICATION_QUOTE_ACTION: { try { DI.InitializeDI(); NotificationType notificationType = intent.GetStringExtra(Constants.NOTIFICTAIONTYPE_KEY) == NotificationType.RandomAlarm.ToString() ? NotificationType.RandomAlarm : NotificationType.DailyAlarm; INotification notification = DI.NotificationService.GetNotification(notificationType); var quotesRepository = ServiceLocator.Current.GetInstance <IQuotesRepository>(); DesignQuote designQuote = await notification.GetDesignQuote(quotesRepository); notification.ToggleNotificationIsSet(false); await NotificationHelper.SendScheduledNotification(context, notification); NotificationHelper.SetScheduledNotifications(context, NotificationService.Notifications); MessagingCenter.Send(SwipeToggled.Message, Helpers.Constants.SWIPE_TOGGLED, true); } catch (Exception ex) { Utils.LogError(ex, "DisplayingQuoteNotification"); } } break; case Constants.SWIPE_ENABLED_ACTION: try { NotificationHelper.SendSwipeEnabledNotification(context); MessagingCenter.Send(SwipeToggled.Message, Helpers.Constants.SWIPE_TOGGLED, true); } catch (Exception ex) { Utils.LogError(ex, "ErrorEnablingSwipe"); } break; } }
public void ShareQuote(DesignQuote quote, bool isLongQuote = false) { throw new NotImplementedException(); }
public static string GetImageText(DesignQuote designQuote) { return($"{designQuote.Quote} \n\n\n{designQuote.Author}\n{Helpers.Constants.BRAND_NAME}"); }
public void ShareQuote(DesignQuote quote, bool isLongQuote = false) { Helper.ShareQuote(Instance, quote, isLongQuote); }