private void AddClient() { var id = _dbContext.GetClients().Any() ? _dbContext.GetClients().Max(i => i.Index) : 0; //If there is none, return 0 _dbContext.Add(new Client() { Name = Name, Age = Age.Value, Index = id + 1, LastName = LastName, Phone = Phone }); Confirm = true; Task.Delay(3000); Confirm = false; }
public HomeViewModel(IDbContextScope dbContext) { _dbContext = dbContext; OrderByAgeCommand = new DelegateCommand(OrderByAge); OrderByIdCommand = new DelegateCommand(OrderById); DeleteClientCommand = new DelegateCommand <Client>(DeleteClient); Clients = _dbContext.GetClients(); }