private async Task UpdateDestinationAsync(string operation, WeekModel weekModel, DeltaModel delta, ShiftModel shift, Func <string, ShiftModel, Task> destinationMethod, ILogger log) { try { await destinationMethod(weekModel.TeamId, shift); } catch (ArgumentException) { delta.SkippedChange(shift); log.LogShiftSkipped(weekModel, operation, shift); } catch (MicrosoftGraphException ex) { delta.FailedChange(shift); log.LogShiftError(ex, weekModel, operation, shift); } catch (Exception ex) { delta.FailedChange(shift); log.LogShiftError(ex, weekModel, operation, shift); } }
private async Task UpdateDestinationAsync(string operation, TeamActivityModel activityModel, DeltaModel <T> delta, T record, Func <string, T, bool, Task> destinationMethod, ILogger log) { try { await destinationMethod(activityModel.TeamId, record, false).ConfigureAwait(false); } catch (ArgumentException) { delta.SkippedChange(record); LogRecordSkipped(activityModel, operation, record, log); } catch (Exception ex) { delta.FailedChange(record); LogRecordError(ex, activityModel, operation, record, log); } }
private async Task AddEmployeesToSchedulingGroupsAsync(DeltaModel <ShiftModel> delta, TeamActivityModel activityModel, ILogger log) { var allShifts = delta.All; var groupLookup = BuildScheduleGroupLookup(allShifts); foreach (var department in groupLookup.Keys) { // get all the user id's in this department var userIds = GetAllUsersInDepartment(allShifts, department); if (userIds.Count > 0) { try { // and add them to the matching schedule group if necessary await _teamsService.AddUsersToSchedulingGroupAsync(activityModel.TeamId, groupLookup[department], userIds).ConfigureAwait(false); } catch (Exception e) { delta.Created.Concat(delta.Updated).Where(i => i.DepartmentName == department).ForEach(i => delta.FailedChange(i)); log.LogSchedulingGroupError(e, activityModel, department, groupLookup[department]); continue; } } } }
private async Task AddEmployeesToSchedulingGroups(DeltaModel delta, IDictionary <string, string> groupLookup, WeekModel weekModel, ILogger log) { var allShifts = delta.All; foreach (var department in groupLookup.Keys) { // get all the user id's in this department var userIds = GetAllUsersInDepartment(allShifts, department); if (userIds.Count > 0) { try { // and add them to the matching schedule group if necessary await _scheduleDestinationService.AddUsersToSchedulingGroupAsync(weekModel.TeamId, groupLookup[department], userIds); } catch (Exception e) { delta.Created.Concat(delta.Updated).Where(i => i.DepartmentName == department).ForEach(i => delta.FailedChange(i)); log.LogSchedulingGroupError(e, weekModel, department, groupLookup[department]); continue; } } } }