/// <summary>
        ///     Riepilogo firmatari
        /// </summary>
        /// <param name="emendamentoUId"></param>
        /// <returns></returns>
        public async Task <IEnumerable <FIRME> > GetFirmatari(EM em, FirmeTipoEnum tipo)
        {
            var firmaProponente = await PRContext
                                  .FIRME
                                  .SingleOrDefaultAsync(f =>
                                                        f.UIDEM == em.UIDEM &&
                                                        f.UID_persona == em.UIDPersonaProponente);

            var query = PRContext
                        .FIRME
                        .Where(f => f.UIDEM == em.UIDEM &&
                               f.UID_persona != em.UIDPersonaProponente);

            switch (tipo)
            {
            case FirmeTipoEnum.TUTTE:
                break;

            case FirmeTipoEnum.PRIMA_DEPOSITO:
                if (em.IDStato >= (int)StatiEnum.Depositato)
                {
                    query = query.Where(f => f.Timestamp < em.Timestamp);
                }

                break;

            case FirmeTipoEnum.DOPO_DEPOSITO:
                query = query.Where(f => f.Timestamp > em.Timestamp);
                break;

            case FirmeTipoEnum.ATTIVI:
                query = query.Where(f => string.IsNullOrEmpty(f.Data_ritirofirma));
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(tipo), tipo, null);
            }

            query = query.OrderBy(f => f.Timestamp);

            var lst = await query
                      .ToListAsync();

            if (firmaProponente != null && tipo != FirmeTipoEnum.DOPO_DEPOSITO)
            {
                lst.Insert(0, firmaProponente);
            }

            return(lst);
        }
Exemple #2
0
        public async Task <IHttpActionResult> GetFirmatari(Guid id, FirmeTipoEnum tipo)
        {
            try
            {
                var em = await _logicEm.GetEM(id);

                if (em == null)
                {
                    return(NotFound());
                }

                var result = await _logicFirme.GetFirme(em, tipo);

                return(Ok(result));
            }
            catch (Exception e)
            {
                Log.Error("GetFirmatari", e);
                return(ErrorHandler(e));
            }
        }
        public async Task <IEnumerable <FirmeDto> > GetFirme(EM em, FirmeTipoEnum tipo)
        {
            try
            {
                var firmeInDb = await _unitOfWork
                                .Firme
                                .GetFirmatari(em, tipo);

                var firme = firmeInDb.ToList();

                if (!firme.Any())
                {
                    return(new List <FirmeDto>());
                }

                var result = new List <FirmeDto>();
                foreach (var firma in firme)
                {
                    var firmaDto = new FirmeDto
                    {
                        UIDEM            = firma.UIDEM,
                        UID_persona      = firma.UID_persona,
                        FirmaCert        = Decrypt(firma.FirmaCert),
                        Data_firma       = Decrypt(firma.Data_firma),
                        Data_ritirofirma = string.IsNullOrEmpty(firma.Data_ritirofirma)
                        ? null
                        : Decrypt(firma.Data_ritirofirma)
                    };

                    result.Add(firmaDto);
                }

                return(result);
            }
            catch (Exception e)
            {
                Log.Error("Logic - GetFirme", e);
                throw e;
            }
        }
Exemple #4
0
        /// <summary>
        ///     Ritorna la lista dei firmatari per visualizzazione client
        /// </summary>
        /// <param name="firme"></param>
        /// <param name="currentUId"></param>
        /// <param name="tipo"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public static async Task <string> GetFirmatariEM(IEnumerable <FirmeDto> firme, Guid currentUId,
                                                         FirmeTipoEnum tipo,
                                                         bool tag = false)
        {
            try
            {
                if (firme == null)
                {
                    return(string.Empty);
                }
                var firmeDtos = firme.ToList();
                if (!firmeDtos.Any())
                {
                    return(string.Empty);
                }

                if (tag)
                {
                    var result = new List <string>();

                    var firmaProponente = firmeDtos.First();
                    var proponente      = await ApiGateway.GetPersona(firmaProponente.UID_persona);

                    result.Add(_chipTemplate.Replace("{{foto}}", proponente.foto)
                               .Replace("{{DisplayName}}", $"<b>{firmaProponente.FirmaCert}</b>")
                               .Replace("{{OPZIONALE}}", ""));
                    firmeDtos.Remove(firmaProponente);

                    foreach (var firmeDto in firmeDtos)
                    {
                        var persona = await ApiGateway.GetPersona(firmeDto.UID_persona);

                        if (string.IsNullOrEmpty(firmeDto.Data_ritirofirma))
                        {
                            result.Add(_chipTemplate.Replace("{{foto}}", persona.foto)
                                       .Replace("{{DisplayName}}", $"{firmeDto.FirmaCert}").Replace("{{OPZIONALE}}", ""));
                        }
                        else
                        {
                            result.Add(
                                $"<span style='text-decoration:line-through;color:grey'>{firmeDto.FirmaCert}</span>");
                        }
                    }

                    return(result.Aggregate((i, j) => i + j));
                }

                var titoloColonna = tipo == FirmeTipoEnum.DOPO_DEPOSITO
                    ? "Firme aggiunte dopo il deposito"
                    : "Firmatari dell'emendamento";
                var table = @"
                    <table class='highlight'>
                        <thead>
                          <tr>
                              <th>{{titoloColonna}}</th>
                              <th>Data Firma</th>
                              <th>Data Ritiro Firma</th>
                          </tr>
                        </thead>
                        <tbody>
                        {{BODY_FIRME}}
                        </tbody>
                    </table>";
                var body  = string.Empty;
                var em    = await ApiGateway.GetEmendamento(firmeDtos.Select(f => f.UIDEM).First());

                foreach (var firmeDto in firmeDtos)
                {
                    body += "<tr>";

                    if (!string.IsNullOrEmpty(firmeDto.Data_ritirofirma))
                    {
                        body += $"<td><del>{firmeDto.FirmaCert}</del></td>";
                        body += $"<td><del>{firmeDto.Data_firma}</del></td>";
                        body += $"<td>{firmeDto.Data_ritirofirma}</td>";
                    }
                    else
                    {
                        body += $"<td>{firmeDto.FirmaCert}</td>";
                        body += $"<td>{firmeDto.Data_firma}</td>";
                        if (currentUId == firmeDto.UID_persona)
                        {
                            if (em.STATI_EM.IDStato >= (int)StatiEnum.Depositato)
                            {
                                body +=
                                    $"<td><div class='chip red center white-text' onclick=\"RitiraFirma('{firmeDto.UIDEM}')\"><i class='icon material-icons'>delete</i> Ritira</div></td>";
                            }
                            else
                            {
                                body +=
                                    $"<td><div class='chip red center white-text' onclick=\"EliminaFirma('{firmeDto.UIDEM}')\"><i class='icon material-icons'>delete</i> Elimina</div></td>";
                            }
                        }
                        else
                        {
                            body += "<td></td>";
                        }
                    }

                    body += "</tr>";
                }

                return(table.Replace("{{titoloColonna}}", titoloColonna).Replace("{{BODY_FIRME}}", body));
            }
            catch (Exception e)
            {
                Log.Error("GetFirmatariEM", e);
                throw e;
            }
        }
Exemple #5
0
        public async Task <IEnumerable <FirmeDto> > GetFirmatari(Guid emendamentoUId, FirmeTipoEnum tipo)
        {
            try
            {
                var requestUrl = $"{apiUrl}/emendamenti/firmatari?id={emendamentoUId}&tipo={tipo}";

                var lst = JsonConvert.DeserializeObject <IEnumerable <FirmeDto> >(await Get(requestUrl, _token));

                return(lst);
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.Error("GetFirmatari", ex);
                throw ex;
            }
            catch (Exception ex)
            {
                Log.Error("GetFirmatari", ex);
                throw ex;
            }
        }
Exemple #6
0
        public async Task <IEnumerable <FIRME> > GetFirme(EmendamentiDto emDto, FirmeTipoEnum tipo)
        {
            var em = await _unitOfWork.Emendamenti.Get(emDto.UIDEM);

            return(await GetFirme(em, tipo));
        }
        /// <summary>
        ///     Ritorna la lista dei firmatari per visualizzazione client
        /// </summary>
        /// <param name="firme"></param>
        /// <param name="currentUId"></param>
        /// <param name="tipo"></param>
        /// <param name="tag"></param>
        /// <returns></returns>
        public static async Task <string> GetFirmatariEM(IEnumerable <FirmeDto> firme, Guid currentUId,
                                                         FirmeTipoEnum tipo,
                                                         string token,
                                                         bool tag = false)
        {
            try
            {
                if (firme == null)
                {
                    return(string.Empty);
                }
                var firmeDtos = firme.ToList();
                if (!firmeDtos.Any())
                {
                    return(string.Empty);
                }

                var apiGateway = new ApiGateway(token);

                if (tag)
                {
                    var result = new List <string>();

                    var firmaProponente = firmeDtos.First();
                    var proponente      = await apiGateway.Persone.Get(firmaProponente.UID_persona);

                    if (string.IsNullOrEmpty(firmaProponente.Data_ritirofirma))
                    {
                        result.Add(_chipTemplate.Replace("{{foto}}", proponente.foto)
                                   .Replace("{{DisplayName}}", $"<b>{firmaProponente.FirmaCert}</b>")
                                   .Replace("{{OPZIONALE}}", ""));
                    }
                    else
                    {
                        result.Add(_chipTemplate.Replace("{{foto}}", proponente.foto)
                                   .Replace("{{DisplayName}}", $"<span style='text-decoration:line-through;color:grey'>{firmaProponente.FirmaCert}</span>")
                                   .Replace("{{OPZIONALE}}", ""));
                    }
                    firmeDtos.Remove(firmaProponente);

                    foreach (var firmeDto in firmeDtos)
                    {
                        var persona = await apiGateway.Persone.Get(firmeDto.UID_persona);

                        if (string.IsNullOrEmpty(firmeDto.Data_ritirofirma))
                        {
                            result.Add(_chipTemplate.Replace("{{foto}}", persona.foto)
                                       .Replace("{{DisplayName}}", $"{firmeDto.FirmaCert}").Replace("{{OPZIONALE}}", ""));
                        }
                        else
                        {
                            result.Add(
                                $"<span style='text-decoration:line-through;color:grey'>{firmeDto.FirmaCert}</span>");
                        }
                    }

                    return(result.Aggregate((i, j) => i + j));
                }

                var titoloColonna = tipo == FirmeTipoEnum.DOPO_DEPOSITO
                    ? "Firme aggiunte dopo il deposito"
                    : "Firmatari dell'emendamento";
                var table = "<ul class=\"collection\">{{BODY_FIRME}}</ul>";
                var body  = "<li class=\"collection-header\"><h4 style=\"margin-left:10px\">Firmatari</h4></li>";
                var em    = await apiGateway.Emendamento.Get(firmeDtos.Select(f => f.UIDEM).First());

                foreach (var firmeDto in firmeDtos)
                {
                    body += "<li class=\"collection-item with-header\">";

                    if (!string.IsNullOrEmpty(firmeDto.Data_ritirofirma))
                    {
                        body += $"<div><del>{firmeDto.FirmaCert}</del>";
                        body += $"<br/><label>firmato il </label><del>{firmeDto.Data_firma}</del>";
                        body += $"<br/><label>ritirato il </label>{firmeDto.Data_ritirofirma}</div>";
                    }
                    else
                    {
                        body += $"<div>{firmeDto.FirmaCert}";
                        body += $"<br/><label>firmato il </label>{firmeDto.Data_firma}";
                        if (currentUId == firmeDto.UID_persona)
                        {
                            if (em.IDStato >= (int)StatiEnum.Depositato)
                            {
                                body +=
                                    $"<a class='chip red center white-text secondary-content' style=\"min-width:unset;margin-top:-16px\" onclick=\"RitiraFirma('{firmeDto.UIDEM}')\"><i class='icon material-icons'>delete</i> Ritira</a>";
                            }
                            else
                            {
                                body +=
                                    $"<a class='chip red center white-text secondary-content' style=\"min-width:unset;margin-top:-16px\" onclick=\"EliminaFirma('{firmeDto.UIDEM}')\"><i class='icon material-icons'>delete</i> Elimina</a>";
                            }
                        }
                    }

                    body += "</li>";
                }

                return(table.Replace("{{titoloColonna}}", titoloColonna).Replace("{{BODY_FIRME}}", body));
            }
            catch (Exception e)
            {
                Log.Error("GetFirmatariEM", e);
                throw e;
            }
        }