private async void ExecuteEditarGroupoOfertasAsync(GrupoOferta grupoOferta) { if (NotSharing) { var parameters = new Dictionary <string, string>(); parameters.Add("ID", grupoOferta.Id); await PushAsync <NovoGrupoOfertaPageViewModel>(false, parameters); } else { if (await MessageDisplayer.Instance.ShowAskAsync("Compartilhar Oferta", $"Você tem certeza que deseja compartilhar a oferta selecionada com o grupo {grupoOferta.Name} ?", "Sim", "Não")) { var body = new CompartilhamentoOfertaGrupo() { Title = $"Nova oferta Compartilhada no grupo {grupoOferta.Name}", Description = $"{azureService.CurrentUser.User.FullName} compartilhou uma nova oferta, clique para mais detalhes", IdGrupo = grupoOferta.Id, IdOferta = CompartilharOfertasPageViewModel.IdSharingOferta, }; await azureService.Client.InvokeApiAsync <CompartilhamentoOfertaGrupo, CompartilhamentoOfertaGrupo>("compartilharOfertaGrupo", body); } await PopAsync <OfertasPageViewModel>(); } }
public async Task ParticiparGrupoAsync(GrupoOferta grupoOferta, ParticipanteGrupo participanteGrupo) { participanteGrupo.IdGrupoOferta = grupoOferta.Id; participanteGrupo.NomeGrupo = grupoOferta.Name; await participantesRepository.CreateEntityAsync(participanteGrupo); await participantesRepository.SyncDataBaseAsync(); }
public async Task CadastrarNovoGrupoUsuarioAsync(GrupoOferta grupoOferta, List <ParticipanteGrupo> participantes) { var idOferta = await grupoRepository.CreateEntityAsync(grupoOferta, true); foreach (var participante in participantes) { participante.IdGrupoOferta = idOferta; participante.NomeGrupo = grupoOferta.Name; await participantesRepository.CreateEntityAsync(participante); } }
private async void SalvarGrupoUsuarioAsync() { if (EditingGroup) { SalvarEdicaoAsync(); } else { var oferta = new GrupoOferta(Name, Private); await grupoOfertaService.CadastrarNovoGrupoUsuarioAsync(oferta, Members.ToList()); } await PopAsync <GruposOfertasPageViewModel>(); }
public async Task AtualizarNovoGrupoUsuarioAsync(GrupoOferta grupoOferta, bool sync) { await grupoRepository.UpdateEntityAsync(grupoOferta); foreach (var participante in grupoOferta?.Participantes) { if (participante.IdGrupoOferta == null) //novo participante { participante.IdGrupoOferta = grupoOferta.Id; participante.NomeGrupo = grupoOferta.Name; await participantesRepository.CreateEntityAsync(participante); } } if (sync) { await participantesRepository.SyncDataBaseAsync(); } }
protected async override void Init(Dictionary <string, string> parameters = null) { if (parameters != null && parameters.ContainsKey("ID")) { EditingGroup = true; editGrupoOferta = await grupoOfertaService.CarregarGrupoOfertaPorIdAsync(parameters["ID"]); AdapterAsync(); } else { EditingGroup = false; var user = azureService.CurrentUser.User; AdicionarParticipante(new ParticipanteGrupo(user.Id) { User = user, Owner = true }); } }
public async Task ExcluirGrupoOfertaAsync(GrupoOferta grupoOferta) { if (grupoOferta == null) { return; } grupoOferta.Participantes = await participantesRepository.SyncTableModel.Where(x => x.IdGrupoOferta == grupoOferta.Id).ToListAsync(); foreach (var participante in grupoOferta?.Participantes) { participante.Delete = true; await participantesRepository.UpdateEntityAsync(participante); //notify ser and delete on server } grupoOferta.Delete = true; await grupoRepository.UpdateEntityAsync(grupoOferta); await grupoRepository.SyncDataBaseAsync(); grupoOferta?.Participantes.ToList().ForEach(async x => await participantesRepository.DeleteEntityAsync(x)); await grupoRepository.DeleteEntityAsync(grupoOferta); }