Example #1
0
 private async void HandleGroupScheduleChanged(object sender, EventArgs args)
 {
     try
     {
         if (args is ParamEventArgs <DayOfWeek> paramEventArgs)
         {
             var group = (IScheduleGroup)sender;
             logger?.LogInformation("Get notification about changed sch in group {0}",
                                    JsonConvert.SerializeObject(group));
             if (groupToUsers.TryGetValue(group, out var list) && list != null && list.Any())
             {
                 logger?.LogInformation("Prepare notification about changed sch in group {0}, users: {1}",
                                        JsonConvert.SerializeObject(group), JsonConvert.SerializeObject(list));
                 var dayName = new CultureInfo("ru-Ru").DateTimeFormat.GetDayName(paramEventArgs.Param);
                 var verbEnd = dayName.EndsWith('а') ? "ась" : "ся";
                 await notifiactionSender.SendNotificationsForIdsAsync(list,
                                                                       $"Изменил{verbEnd} {dayName}");
             }
         }
     }
     catch (Exception e)
     {
         logger?.LogError(e, "Exc");
     }
 }