public ExceptionWindow(string title, string message, IFailable failable, string after = null, ExceptionWindowButtons buttons = ExceptionWindowButtons.OK) { InitializeComponent(); Error = failable; MessageLabel.Text = message + "\n\n" + failable.ToStringSimple() + (after != null ? "\n\n" + after : ""); ExtraInfoLabel.Text = failable.ToStringDetailed(); Text = title; this.Icon = SystemIcons.Warning; if (buttons == ExceptionWindowButtons.OKCancel) { ButtonCancel.Visible = true; this.Width += ButtonCancel.Width; } }
internal static InvalidOperationException DidNotFailException(IFailable failable) { return(new InvalidOperationException(DidNotFailMessage(failable))); }
private static string DidNotFailMessage(IFailable failable) { return($"Unable to retrieve the {nameof(failable.Excuse)} from the {failable.GetType().Name} because {nameof(failable.Failed)} == {failable.Failed}!"); }
protected override async void OnInitialized(EventArgs e) { base.OnInitialized(e); AccountDropDown.Text = iPetrosDI.ConnectedUser.Username; ModeratorsMenuOptionsContainer.Visibility = iPetrosDI.ConnectedUser.Type == StaffMemberType.StaffMember ? Visibility.Collapsed : Visibility.Visible; IFailable <IEnumerable <StaffMemberDataModel> > staffMembersResult = null; if (iPetrosDI.ConnectedUser.Type == StaffMemberType.Admin) { staffMembersResult = await iPetrosDI.GetDataStorage.GetStaffMembersAsync(); } else { staffMembersResult = await iPetrosDI.GetDataStorage.GetStaffMembersAsync(new DateDataStorageArgs() { Include = new List <int>() { iPetrosDI.ConnectedUser.Id } }); } if (!staffMembersResult.Successful) { return; } // Open the calendar await WindowsControlsDI.GetWindowsDialogManager.OpenAsync(Host, "Ημερολόγιο", IconPaths.CalendarPath, () => { var calendar = new iPetrosCalendar(); calendar.Add(new SubCalendarGroup <CalendarEvent>( staffMembersResult.Result.Select(x => new SubCalendar(x.Id.ToString(), "Υπάλληλοι", x.FirstName + " " + x.LastName + " (" + x.Username + ")", x.Color)), async context => { var dictionary = new Dictionary <SubCalendar, IEnumerable <CalendarEvent> >(); var appointmentsResult = await iPetrosDI.GetDataStorage.GetCustomerAppointmentsAsync(new CustomerAppointmentDataStorageArgs() { StaffMembers = context.SubCalendars.Select(x => x.Id.ToInt()).ToList() }); if (!appointmentsResult.Successful) { return new Failable <IDictionary <SubCalendar, IEnumerable <CalendarEvent> > >() { ErrorMessage = appointmentsResult.ErrorMessage } } ; return(new Failable <IDictionary <SubCalendar, IEnumerable <CalendarEvent> > >() { Result = appointmentsResult.Result .GroupBy(x => x.StaffMemberId) .ToDictionary( x => context.SubCalendars.First(y => y.Id == x.Key.ToString()), x => x.Select(y => new CalendarEvent(y.DateStart, y.DateEnd) { Name = y.Customer.FirstName + " " + y.Customer.LastName, Color = y.StaffMember.Color }).ToList().AsEnumerable()) }); })); return(calendar); }, "calendar", false);
public static void ShowImportFailed(string path, IFailable import, IWin32Window owner) { var window = new ExceptionWindow("Failed to load icons", $"The custom icon source at '{path}' failed to load.", import); window.ShowDialog(owner); }