Exemplo n.º 1
0
        /// <summary>
        /// Metodo per la modifica di un corrispondente
        /// </summary>
        /// <param name="request"></param>
        /// <returns>Response</returns>

        public Services.AddressBook.EditCorrespondent.EditCorrespondentResponse EditCorrespondent(Services.AddressBook.EditCorrespondent.EditCorrespondentRequest request)
        {
            logger.Info("BEGIN");
            Services.AddressBook.EditCorrespondent.EditCorrespondentResponse response = Manager.AddressBookManager.EditCorrespondent(request);

            Utils.CheckFaultException(response);
            logger.Info("END");

            return(response);
        }
Exemplo n.º 2
0
        public static Services.AddressBook.EditCorrespondent.EditCorrespondentResponse EditCorrespondent(Services.AddressBook.EditCorrespondent.EditCorrespondentRequest request)
        {
            Services.AddressBook.EditCorrespondent.EditCorrespondentResponse response = new Services.AddressBook.EditCorrespondent.EditCorrespondentResponse();

            try
            {
                DocsPaVO.utente.Utente     utente     = null;
                DocsPaVO.utente.InfoUtente infoUtente = null;

                //Inizio controllo autenticazione utente
                infoUtente = Utils.CheckAuthentication(request, "EditCorrespondent");

                utente = BusinessLogic.Utenti.UserManager.getUtenteById(infoUtente.idPeople);
                if (utente == null)
                {
                    //Utente non trovato
                    throw new PisException("USER_NO_EXIST");
                }
                //Fine controllo autenticazione utente

                if (request == null)
                {
                    throw new PisException("REQUIRED_CORRESPONDENT");
                }

                if (string.IsNullOrEmpty(request.Correspondent.Id))
                {
                    //Corrispondente non trovato
                    throw new PisException("REQUIRED_IDCORRESPONDENT");
                }

                DocsPaVO.utente.Corrispondente corr = BusinessLogic.Utenti.UserManager.getCorrispondenteBySystemIDDisabled(request.Correspondent.Id);

                if (corr == null)
                {
                    //Corrispondente non trovato
                    throw new PisException("CORRESPONDENT_NOT_FOUND");
                }

                string message = string.Empty;

                DocsPaVO.utente.DatiModificaCorr mod = new DocsPaVO.utente.DatiModificaCorr();
                mod = Utils.GetModificaCorrespondentFromPis(request.Correspondent, corr);

                bool result = BusinessLogic.Utenti.UserManager.ModifyCorrispondenteEsterno(mod, infoUtente, out message);

                if (result)
                {
                    //DocsPaVO.utente.Corrispondente corrRes = BusinessLogic.Utenti.UserManager.getCorrispondenteBySystemIDDisabled(request.Correspondent.Id);
                    //DocsPaVO.utente.Corrispondente corrRes = BusinessLogic.Utenti.UserManager.getCorrispondenteByCodRubricaNotDisabled(request.Correspondent.Code, request.Correspondent.Type == "E" ? DocsPaVO.addressbook.TipoUtente.ESTERNO : DocsPaVO.addressbook.TipoUtente.INTERNO, infoUtente);

                    DocsPaVO.utente.Corrispondente corrRes = BusinessLogic.Utenti.UserManager.getCorrispondenteByCodRubricaNotDisabled(request.Correspondent.Code, DocsPaVO.addressbook.TipoUtente.GLOBALE, infoUtente);
                    if (corrRes == null)
                    {
                        corrRes = BusinessLogic.Utenti.UserManager.getCorrispondenteByCodRubricaNotDisabled(request.Correspondent.Code, DocsPaVO.addressbook.TipoUtente.INTERNO, infoUtente);
                    }
                    if (corrRes != null && corrRes.tipoIE == "E" && !string.IsNullOrEmpty(corrRes.email))
                    {
                        if (!string.IsNullOrEmpty(corrRes.email))
                        {
                            List <DocsPaVO.utente.MailCorrispondente> casella = new List <DocsPaVO.utente.MailCorrispondente>();
                            casella.Add(new DocsPaVO.utente.MailCorrispondente()
                            {
                                Email      = corrRes.email,
                                Note       = "",
                                Principale = "1"
                            });

                            BusinessLogic.Utenti.addressBookManager.InsertMailCorrispondente(casella, corrRes.systemId);
                        }
                    }
                    response.Correspondent = Utils.GetCorrespondent(corrRes, infoUtente);
                    response.Success       = true;
                }
                else
                {
                    //Corrispondente non trovato
                    throw new PisException("CORRESPONDENT_NOT_FOUND");
                }
            }
            catch (PisException pisEx)
            {
                logger.ErrorFormat("PISException: {0}, {1}", pisEx.ErrorCode, pisEx.Description);
                response.Error = new Services.ResponseError
                {
                    Code        = pisEx.ErrorCode,
                    Description = pisEx.Description
                };

                response.Success = false;
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Eccezione Generica: APPLICATION_ERROR, {0}", ex.Message);
                response.Error = new Services.ResponseError
                {
                    Code        = "APPLICATION_ERROR",
                    Description = ex.Message
                };

                response.Success = false;
            }

            return(response);
        }