예제 #1
0
        public ApiResponse SendAutomation(LeadToSendAutoEmailModel data)
        {
            var profile = uow.UserProfile.Get(data.UserId);
            var r       = new ApiResponse();

            switch (data.Type)
            {
            case 1:
                string apiKey = "", tokenJson = "";
                if (data.SendFromType == 1)
                {
                    data.ToIntegrationEmail();
                    var apiSite = uow.Integration.GetByAccId(data.UserId, (int)IntegrationType.Gmail, data.FromEmailList[0].Email);  // _dbSet.AsNoTracking().FirstOrDefault(x => x.UserId == userId && x.AccId == accId);
                    if (apiSite != null)
                    {
                        apiKey    = apiSite.ApiKey;
                        tokenJson = apiSite.TokenJson;
                    }
                }
                _log.ErrorFormat("Send email token Json:{0}", tokenJson);
                r = new Utils.EmailUtils().SendLeadAutoReply(data, profile, apiKey, tokenJson);
                break;

            case 2:
                r = new SmsService().SendLeadAutoReply(data, profile);
                break;
            }
            return(r);
        }
        public void recoveryPassowrd(string email, string login)
        {
            var user = context.Users.Where(f => f.Email == email && f.Login == login).FirstOrDefault();

            if (user != null)
            {
                var password = Guid.NewGuid().ToString().Substring(0, 6);
                user.Password = Commons.SecurityUtils.criptografaSenha(password);

                save(user);

                Utils.EmailUtils emailUtils = new Utils.EmailUtils(this.ActiveUser);
                emailUtils.passwordRecovery(user, password);
            }
            else
            {
                throw new Exception("Usuário ou email não encontrado");
            }
        }