Exemplo n.º 1
0
        public async Task SendNotification(AllertaAltreSediCommand command)
        {
            var sintesi = _getSintesiById.GetSintesi(command.CodiceRichiesta);

            var SediDaNotificare = new List <string>();

            if (sintesi.CodSOAllertate != null)
            {
                SediDaNotificare = _getGerarchiaToSend.Get(sintesi.CodSOCompetente, sintesi.CodSOAllertate.ToArray());
            }
            else
            {
                SediDaNotificare = _getGerarchiaToSend.Get(sintesi.CodSOCompetente);
            }

            command.Chiamata = sintesi;
            //Invio la notifica alle competenze della richiesta
            foreach (var sede in SediDaNotificare)
            {
                if (!sede.Equals(sintesi.CodSOCompetente))
                {
                    await _notificationHubContext.Clients.Group(sede).SendAsync("NotifyAllertaAltreSedi", sintesi);
                }

                await _notificationHubContext.Clients.Group(sede).SendAsync("ModifyAndNotifySuccess", command);
            }

            if (command.CodSediAllertateOld != null)
            {
                foreach (var sede in command.CodSediAllertateOld)
                {
                    await _notificationHubContext.Clients.Group(sede).SendAsync("NotifyDeleteAllertaAltreSedi", command.CodiceRichiesta);
                }
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AllertaSedi([FromBody] AllertaAltreSediCommand parametri)
        {
            var idOperatore = Request.Headers["IdUtente"];

            parametri.CodUtente = idOperatore;

            try
            {
                this._allertaSediHandler.Handle(parametri);
                return(Ok());
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains(Costanti.UtenteNonAutorizzato))
                {
                    return(StatusCode(403, new { message = Costanti.UtenteNonAutorizzato }));
                }
                else
                {
                    return(BadRequest(new { message = ex.Message }));
                }
            }
        }