public async Task Claim(int rotationId) { var answer = await Application.Current.MainPage.DisplayAlert("Confirm", $"Claim this rotation?", "Yes", "No"); if (answer) { Helper helper = new Helper(); var isLocked = await helper.IsLocked(); if (isLocked) { await Application.Current.MainPage.DisplayAlert("Warning", "No rotations can be placed at this time, some changes are being made. Plese try again later.", "OK"); } else { Model.Buy buy = new Model.Buy() { Item = BuyItem.Rotation, ItemId = rotationId, UserId = APIService.User.UserId }; try { await _usersApi.Buy <string>(buy); await Application.Current.MainPage.DisplayAlert("Success", "You have claimed the rotation successfully!", "OK"); } catch { await Application.Current.MainPage.DisplayAlert("Oops", $"You have already claimed this rotation!", "OK"); } } } }
public async Task Subscribe(int subId, decimal price) { var answer = await Application.Current.MainPage.DisplayAlert("Confirm", $"Are you sure you want to subscribe for {price}/month?", "Yes", "No"); if (answer) { Helper helper = new Helper(); var isLocked = await helper.IsLocked(); if (isLocked) { await Nav.PopAsync(); await Application.Current.MainPage.DisplayAlert("Warning", "No subscriptions can be placed at this time, some changes are being made. Plese try again later.", "OK"); } else { Model.Buy buy = new Model.Buy() { Item = BuyItem.Subscription, ItemId = subId, UserId = APIService.User.UserId }; try { await _usersApi.Buy <string>(buy); await Application.Current.MainPage.DisplayAlert("Success", "You have subscribed successfully!", "OK"); } catch { await Application.Current.MainPage.DisplayAlert("Oops", $"You are already subscribed to this subscription box!", "OK"); } } } }
public async Task Buy() { var answer = await Application.Current.MainPage.DisplayAlert("Confirm", $"Buy '{Show.Title}' for {Show.Price}?", "Yes", "No"); if (answer) { Helper helper = new Helper(); var isLocked = await helper.IsLocked(); if (isLocked) { await Nav.PopAsync(); await Application.Current.MainPage.DisplayAlert("Warning", "No orders can be placed at this time, some changes are being made. Plese try again later.", "OK"); } else { Model.Buy buy = new Model.Buy() { Item = BuyItem.Show, ItemId = Show.ShowId, UserId = APIService.User.UserId }; try { await _usersApi.Buy <string>(buy); await Nav.PopAsync(); await Application.Current.MainPage.DisplayAlert("Success", "Show bought successfully", "OK"); } catch { await Nav.PopAsync(); await Application.Current.MainPage.DisplayAlert("Oops", $"You already bought '{Show.Title}'", "OK"); } } } }