Exemplo n.º 1
0
        public async Task <IActionResult> Delete(string Id)
        {
            try
            {
                var command = new DeleteEnteCommand()
                {
                    CodiceSede  = Request.Headers["codicesede"].ToString().Split(','),
                    idOperatore = Request.Headers["IdUtente"],
                    Id          = Id
                };

                _deleteEnteHandler.Handle(command);

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

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


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

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

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