async public Task Remove (AccessProfiles accessProfile)
		{
			await new Repository<AccessProfiles> ().RemoveAsync (accessProfile);
		}
		public GerenciarPerfisViewModel (INavigation navigation, AccessProfiles accessProfileEdit = null)
		{
            
			Navigation = navigation;
			listHorariosDisponiveis = new ObservableCollection<AccessTimes> (new Repository<AccessTimes> ().GetAllAsync ().Result.Where (at => at.UserId == Settings.user_Id).OrderBy (ac => ac.Name));
			listHorariosAdicionados = new ObservableCollection<AccessTimes> ();
			if (accessProfileEdit != null) {
				AccessProfileEdit = accessProfileEdit;
				//Monta lista dos adicionados
				AccessTimes at;
				int pos;
				for (int i = 0; i < 8; i++)
					if (!string.IsNullOrEmpty (AccessProfileEdit.AcessTimeId (i))) {

						at = new AccessTimes (AccessProfileEdit.AcessTimeId (i));
						if ((pos = listHorariosDisponiveis.IndexOf (at)) >= 0) {
							//                          Console.WriteLine("Adicionou:" + listHorariosDisponiveis[pos].Name);
							listHorariosDisponiveis [pos].IsSelected = true;
							listHorariosAdicionados.Add (listHorariosDisponiveis [pos]);
							listHorariosDisponiveis.RemoveAt (pos);
						}
						//foreach (var disponivel in listHorariosDisponiveis)
						//{
						//    if (!listHorariosAdicionados.Contains(disponivel))
						//        listHorariosAdicionados.Add(disponivel);
						//}
					}

				IsEditing = true;
				IsAutoMovel = accessProfileEdit.IsA;
				IsPedestre = accessProfileEdit.IsP;
				//formato= ddMMyy
				ExpireDate = new DateTime (Int32.Parse (accessProfileEdit.Expire.Substring (4, 2)),// ano
					Int32.Parse (accessProfileEdit.Expire.Substring (2, 2)),  //mes
					Int32.Parse (accessProfileEdit.Expire.Substring (0, 2)),  //dia
					0, 0, 0, DateTimeKind.Local);

				Name = accessProfileEdit.Name;
			} else {
				AccessProfileEdit = new AccessProfiles ();
				ExpireDate = DateTime.Today.AddYears (1);
			}

			CommandSaveProfile = new Command (async () => {
				if (string.IsNullOrEmpty (Name)) {
					Clean = false;
					await notificator.Notify (ToastNotificationType.Error, "Erro", "Nome é obrigatório", TimeSpan.FromSeconds (2));
					return;
				}

				if (!IsAutoMovel && !IsPedestre) {
					Clean = false;
					await notificator.Notify (ToastNotificationType.Error, "Erro",
						"Perfil deve ter pelo menos um tipo de acesso", TimeSpan.FromSeconds (2));
					return;
				}

				if ((listHorariosAdicionados == null || listHorariosAdicionados.Count == 0)) {
					await notificator.Notify (ToastNotificationType.Error, "Erro",
						"Perfil deve ter pelo menos um horário", TimeSpan.FromSeconds (2));
					return;
				}

				if (!IsEditing && new Repository<AccessProfiles> ().GetAllAsync ().Result.Any (ap => ap.Name == Name)) {
					Clean = false;
					await notificator.Notify (ToastNotificationType.Error, "Erro", "Perfil com esse nome já existe", TimeSpan.FromSeconds (2));
					return;
				}

				AccessProfileEdit.Expire = String.Format ("{0:ddMMyy}", ExpireDate);
				AccessProfileEdit.IsA = IsAutoMovel;
				AccessProfileEdit.IsP = IsPedestre;
				AccessProfileEdit.Name = Name;

				int fim = listHorariosAdicionados.Count;
				for (int i = 0; i < 8; i++) {
					if (i < fim)
						AccessProfileEdit.AcessTimeId (i, listHorariosAdicionados [i].Id);
					else
						AccessProfileEdit.AcessTimeId (i, string.Empty);
				}

				if (IsEditing) {
					await new Repository<AccessProfiles> ().UpdateAsync (AccessProfileEdit);
					await notificator.Notify (ToastNotificationType.Info, "MySafety", "Perfil atualizado", TimeSpan.FromSeconds (3));
				} else {
					AccessProfileEdit.Id = Guid.NewGuid ().ToString ();
					AccessProfileEdit.UserId = Settings.user_Id;
					Clean = true;
					Name = string.Empty;
					ExpireDate = DateTime.Today.AddYears (1);
					IsAutoMovel = false;
					IsPedestre = false;
					await notificator.Notify (ToastNotificationType.Success, "MySafety", "Perfil adicionado", TimeSpan.FromSeconds (2));
					await new Repository<AccessProfiles> ().CreateAsync (AccessProfileEdit);
				}

			});
		}
 public bool Equals(AccessProfiles other)
 {
     if (other == null)
         return false;
     return ((Name).Equals (other.Name));
 }