private void RegistrarCommands() { CameraCommand = new Command(() => { MessagingCenter.Send <AtendimentoFoto>(this.AtendimentoFoto, "Camera"); }); AlbumCommand = new Command(() => { MessagingCenter.Send <AtendimentoFoto>(this.AtendimentoFoto, "Album"); }); GravarFotoCommand = new Command(async() => { AtendimentoFoto.Atendimento = AtendimentoFoto.Atendimento; AtendimentoFoto.AtendimentoID = AtendimentoFoto.Atendimento.AtendimentoID; var dal = new AtendimentoFotoDAL(AtendimentoFoto.Atendimento, DependencyService.Get <IDBPath>().GetDbPath()); await dal.UpdateAsync(AtendimentoFoto, AtendimentoFoto.AtendimentoFotoID); MessagingCenter.Send <string>("Atualização realizada com sucesso.", "InformacaoCRUD"); MessagingCenter.Send <string>("consultar.png", "AtualizarFoto"); AtendimentoFoto = new AtendimentoFoto(); OnPropertyChanged(nameof(Observacoes)); }, () => { return(!string.IsNullOrEmpty(Observacoes) && !string.IsNullOrEmpty(CaminhoFoto)); }); }
public async Task EliminarAtendimento(Atendimento atendimento) { var fotosDAL = new AtendimentoFotoDAL(atendimento, DependencyService.Get <IDBPath>().GetDbPath()); await atendimentoDAL.DeleteAsync(atendimento); Atendimentos.Remove(atendimento); }
public override async Task DeleteAsync(Atendimento atendimento, object databaseContext = null) { using (var context = (databaseContext == null) ? DatabaseContext.GetContext(dbPath) : (DatabaseContext)databaseContext) { var servicosDAL = new AtendimentoItemDAL(atendimento, dbPath); var fotosDAL = new AtendimentoFotoDAL(atendimento, dbPath); context.AtendimentoItens.RemoveRange(await servicosDAL.GetAllAsync()); context.AtendimentoFotos.RemoveRange(await fotosDAL.GetAllAsync()); await base.DeleteAsync(atendimento, context); } }
public async Task EliminarAtendimentoAsync(Atendimento atendimento) { var fotosDAL = new AtendimentoFotoDAL(atendimento, DependencyService.Get <IDBPath>().GetDbPath()); var fotos = await fotosDAL.GetAllAsync(); await atendimentoDAL.DeleteAsync(atendimento); foreach (var foto in fotos) { File.Delete(DependencyService.Get <IFotoLoadMediaPlugin>().GetPathToPhoto(foto.CaminhoFoto)); } Atendimentos.Remove(atendimento); }