Example #1
0
        public async Task <IActionResult> Add(EnteIntervenuto ente)
        {
            try
            {
                var command = new AddEnteCommand()
                {
                    CodiceSede  = Request.Headers["codicesede"].ToString().Split(','),
                    idOperatore = Request.Headers["IdUtente"],
                    Ente        = ente
                };

                _addEnteHandler.Handle(command);

                return(Ok());
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains(Costanti.UtenteNonAutorizzato))
                {
                    return(StatusCode(403, new { message = Costanti.UtenteNonAutorizzato }));
                }
                else
                {
                    return(BadRequest(ex));
                }
            }
        }
Example #2
0
        public async Task SendNotification(AddEnteCommand command)
        {
            var SediDaNotificare = new List <string>();

            if (command.Ente.Ricorsivo)
            {
                SediDaNotificare = _getGerarchiaToSend.Get(command.CodiceSede[0]);
            }
            else
            {
                SediDaNotificare.Add(command.CodiceSede[0]);
            }


            var count   = _getRurbica.CountBylstCodiciSede(SediDaNotificare.ToArray());
            var lstEnti = _getRurbica.Get(command.CodiceSede, null);

            foreach (var sede in SediDaNotificare)
            {
                await _notificationHubContext.Clients.Group(sede).SendAsync("NotifyAddEnte", new
                {
                    Pagination = new Paginazione()
                    {
                        TotalItems = count
                    }
                });

                await _notificationHubContext.Clients.Group(sede).SendAsync("NotifyChangeEnti", lstEnti);
            }
        }