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; }