Exemple #1
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            EventoClient            eventoClient   = new EventoClient(await ApiHelper.GetApiClient());
            PartecipazioneDtoOutput partecipazione = await eventoClient.GetPartecipazioniRegaloAsync(new Guid(Regalo.Id));

            lvPartecipanti.ItemsSource = partecipazione.UtentiPartecipanti.ToList();
            if (partecipazione.NumeroAnonimi.HasValue && partecipazione.NumeroAnonimi.Value > 0)
            {
                NumeroPartecipanti.Text = partecipazione.NumeroAnonimi.ToString();
                LabelAnonimi.IsVisible  = true;
            }
        }
Exemple #2
0
        public async Task <PartecipazioneDtoOutput> GetPartecipazioniRegalo(Guid IdRegalo)
        {
            DateTime dataEvento = await dbDataContext.Regalo.Include(x => x.Evento)
                                  .Where(x => x.Id == IdRegalo)
                                  .Select(x => x.Evento.DataEvento).FirstOrDefaultAsync();

            List <UtentePartecipazioneDtoOutput> partecipanti = await dbDataContext.RegaloUserPartecipazione
                                                                .Join(dbDataContext.UserInfo,                                                                               // the source table of the inner join
                                                                      partecipazione => partecipazione.IdUser,                                                              // Select the primary key (the first part of the "on" clause in an sql "join" statement)
                                                                      userInfo => userInfo.IdAspNetUser,                                                                    // Select the foreign key (the second part of the "on" clause)
                                                                      (partecipazione, userInfo) => new { RegaloUserPartecipazione = partecipazione, UserInfo = userInfo }) // selection
                                                                .Where(partecipazioneAndUserInfo =>
                                                                       (partecipazioneAndUserInfo.RegaloUserPartecipazione.IdRegalo == IdRegalo)
                                                                       )
                                                                .Select(partecipazioneAndUserInfo => new UtentePartecipazioneDtoOutput()
            {
                IdRegalo            = partecipazioneAndUserInfo.RegaloUserPartecipazione.IdRegalo,
                IdUserPartecipante  = partecipazioneAndUserInfo.RegaloUserPartecipazione.IdUser,
                CognomePartecipante = partecipazioneAndUserInfo.UserInfo.Cognome,
                NomePartecipante    = partecipazioneAndUserInfo.UserInfo.Nome,
                Anonimo             = partecipazioneAndUserInfo.RegaloUserPartecipazione.Anonimo
            }).Distinct()
                                                                .ToListAsync();


            int anonimi = 0;

            if (dataEvento.Date > DateTime.Today) //Evento futuro
            {
                anonimi = partecipanti.Where(x => x.Anonimo).Count();
                partecipanti.RemoveAll(x => x.Anonimo);
            }

            PartecipazioneDtoOutput res = new PartecipazioneDtoOutput();

            res.NumeroAnonimi      = anonimi;
            res.UtentiPartecipanti = partecipanti;

            return(res);
        }