public async Task LoadMenu() { try { flowTop.SuspendLayout(); flowItems.SuspendLayout(); lblPath.Text = "/"; flowTop.Controls.Clear(); flowItems.Controls.Clear(); IEnumerable <MenuCategory> result; try { result = await Application.Api(LoadingState).Menu.GetMenu(); } catch (Exception mex) { GlobalHandler.Catch(mex, ParentForm); return; } var tree = result.ToTree(mc => mc.Id, mc => mc.ParentId); flowTop.Controls.AddRange(tree.Select(CreateMenuButon).Cast <Control>().ToArray()); } finally { flowTop.ResumeLayout(); flowItems.ResumeLayout(); } }
private async void OnUserAuthorisationChanged(object sender, AuthorisationChangedArgs args) { if (Connection == null) { return; } if (Connection.Headers.ContainsKey(UserIdentity.AUTHORISATION_HEADER)) { Connection.Headers.Remove(UserIdentity.AUTHORISATION_HEADER); } try { if (args.Identity != null) { Connection.Headers.Add(UserIdentity.AUTHORISATION_HEADER, args.Identity.Id.GetHashCode().ToString()); var connectionId = await Hub.Invoke <string>(SignalRHub.Events.Account.RegisterClient, args.Identity); args.Identity.ConnectionId = connectionId; } else { await Hub.Invoke(SignalRHub.Events.Account.RemoveClient); } } catch (Exception ex) { GlobalHandler.Catch(ex); } }
public async Task Initialize(ApiClient client) { try { SuspendLayout(); foreach (Control ctrl in pnlZones.Controls) { ctrl.Dispose(); } pnlZones.Controls.Clear(); if (_zones != null) { foreach (var tables in _zones.Values) { foreach (var table in tables) { table.Dispose(); } tables.Clear(); } _zones.Clear(); } var zones = await client.Layout.GetAllZones(); var lzones = zones.OrderBy(z => z.Order).ThenBy(z => z.Name).ThenBy(z => z.Id).ToList(); var czones = lzones.Select(CreateZoneControl).Cast <Control>().ToArray(); pnlZones.Controls.AddRange(czones); foreach (var zone in lzones) { if (!_zones.ContainsKey(zone.Id)) { _zones.Add(zone.Id, new List <CtrlTable>()); } _zones[zone.Id].AddRange(zone.Tables?.Select(CreateTableControl) ?? new CtrlTable[0]); } if (czones.Length >= 1) { SelectZone((CtrlWorkspaceZone)czones[0]); } } catch (Exception ex) { GlobalHandler.Catch(ex, ParentForm); } finally { ResumeLayout(); } }
private async void btnPay_Click(object sender, EventArgs e) { try { var result = UiHelper.ShowConfirmation($"Esti sigur ca vrei sa inchizi masa {_order.Table?.Name}?", MessageType.Info, $"Comanda {_order.Number}", ParentForm); if(result != DialogResult.Yes) return; await Application.Api(ParentForm.LoadingState).Order.Pay(_order); await BackToTables(); } catch (Exception exception) { GlobalHandler.Catch(exception, ParentForm); } }
private async Task SendOrder() { try { if ((_order.Items?.Count() ?? 0) <= 0) { ParentForm.PresentMessage("Nu se poate trimite o comanda goala. Adaugati produse dupa incercati din nou.", MessageType.Warning); return; } var order = await Application.Api(LoadingState).Order.SendOrder(_order); await OnOrderSent(new OrderSentEventArgs(order)); await BackToTables(); } catch (Exception ex) { GlobalHandler.Catch(ex, ParentForm); } }