Skip to content

Instantly share code, notes, and snippets.

@Sa1Gur
Created August 19, 2019 23:05
Show Gist options
  • Save Sa1Gur/4e527beaa0f1ce3d88c96247c2ffcec8 to your computer and use it in GitHub Desktop.
Save Sa1Gur/4e527beaa0f1ce3d88c96247c2ffcec8 to your computer and use it in GitHub Desktop.
...
namespace In2TeamsSplitter.ViewModels
{
class TeamMatesViewModel : INotifyPropertyChanged
{
...
public TeamMatesViewModel()
{
AddNewTeamMateCommand = new Command(() => AddNewTeamMate());
...
}
public Command AddNewTeamMateCommand { get; }
private void AddNewTeamMate()
{
try
{
if (string.IsNullOrEmpty(AddName)) throw new Exception("Valid name required");
int _ = conn.Insert(new TeamMateItem { Name = AddName, Level = AddLevel });
TeamMateSquad.Add(new TeamMateItem { Name = AddName, Level = AddLevel });
AddName = string.Empty;
AddLevel = uint.MinValue;
}
catch (Exception ex)
{
Application.Current.MainPage.DisplayAlert("error", $"Failed to add {AddName}. Error: {ex.Message}", "Ok");
}
}
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment