Пример #1
0
        public GenericStatusModel NewsLetterRegister([FromBody] NewsLetterRegister request)
        {
            GenericStatusModel gsm = new GenericStatusModel();

            int lang = 2;

            if (request.Lang >= 2 && request.Lang <= 4)
            {
                lang = request.Lang;
            }

            RacMsg msgs = RacMsg.cache.GetMessage((RacMsg.Language)lang);

            if (request.Type == 1)
            {
                if (!LibVisLib.Verify.AcceptEmail(request.Data))
                {
                    gsm.Result           = (int)RacMsg.Id.Error;
                    gsm.ResultComplement = msgs.Get(RacMsg.Id.InvalidCharactersInTheEmail);
                    RacWebLog.log.Log(RacWebLog.LogType.Error, "Invalid email format: " + request.Data);
                }
                else
                {
                    RacWebLog.log.Log(RacWebLog.LogType.Informative, "Registro de email para newsletter: " + request.Data);
                    NewsLetter.AddNewsLetterEmail(request.Data);

                    gsm.Result           = 0;
                    gsm.ResultComplement = "";
                }
            }
            else
            {
                gsm.Result           = (int)RacMsg.Id.Error;
                gsm.ResultComplement = msgs.Get(RacMsg.Id.InvalidType);
                RacWebLog.log.Log(RacWebLog.LogType.Error, "Tipo de registro inválido: " + request.Type.ToString());
            }

            return(gsm);
        }