Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. foreach (var goal in goals)
  2.             {
  3.                 var text = string.Format(AppResources.GoalsReminderNotification, goal.Name);
  4.  
  5.                 var count = await GoalComment.GetFromParent(goal.Id).CountAsync();
  6.  
  7.                 int days;
  8.  
  9.                 if (goal.Period.Equals(Goal.MonthPeriod))
  10.                     days = 5;
  11.                 else if (goal.Period.Equals(Goal.YearPeriod))
  12.                     days = 14;
  13.                 else
  14.                     days = 60;
  15.  
  16.                 if (count == 0) //if user hasn't left a comment to the goal
  17.                 {
  18.                     if (DateTime.Today >= goal.CreatedAt.Value.AddDays(days) + goal.Period)
  19.                     {
  20.                         ShowGoalReminderNotification(id, text, goal.Id);
  21.                     }
  22.  
  23.                     continue;
  24.                 }
  25.  
  26.                 var comments = await GoalComment.GetFromParent(goal.Id).ToListAsync();
  27.  
  28.                 var lastComment = comments[comments.Count - 1];
  29.  
  30.                 if (DateTime.Today >= lastComment.CreatedAt.Value.AddDays(days))
  31.                 {
  32.                     ShowGoalReminderNotification(id, text, goal.Id);
  33.                 }
  34.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement