public async Task <IActionResult> MergeSchede([FromBody] SchedaContatto scheda) { string idUtente = Request.Headers["IdUtente"]; var command = new MergeSchedeNueCommand() { CodiceSede = Request.Headers["codiceSede"], IdUtente = idUtente, SchedaNue = scheda }; try { _setMerge.Handle(command); return(Ok()); } catch (Exception ex) { if (ex.Message.Contains(Costanti.UtenteNonAutorizzato)) { return(StatusCode(403, Costanti.UtenteNonAutorizzato)); } return(BadRequest()); } }
public async Task SendNotification(MergeSchedeNueCommand command) { var getConteggioSchedeQuery = new GetConteggioSchedeQuery { CodiciSede = new string[] { command.CodiceSede } }; var infoNue = _getConteggioSchedeHandler.Handle(getConteggioSchedeQuery).InfoNue; await _notificationHubContext.Clients.Group(command.CodiceSede).SendAsync("NotifyGetContatoriSchedeContatto", infoNue); await _notificationHubContext.Clients.Group(command.CodiceSede).SendAsync("NotifyUpdateSchedaContatto", command.SchedaNue); var codiciSchedecollegate = new string[command.SchedaNue.Collegate.Count]; int i = 0; foreach (var schedaCollegata in command.SchedaNue.Collegate) { codiciSchedecollegate[i] = schedaCollegata.CodiceScheda; i++; } await _notificationHubContext.Clients.Group(command.CodiceSede).SendAsync("NotifyRemoveSchedeContatto", codiciSchedecollegate); }