public async Task EmailSendAsync(string UserID, int Status, string PairName, string BaseMarket
                                         , string TrnDate, decimal ReqAmount = 0, decimal Amount = 0, decimal Fees = 0)
        {
            try
            {
                if (!string.IsNullOrEmpty(UserID) && !string.IsNullOrEmpty(PairName) && !string.IsNullOrEmpty(BaseMarket) &&
                    ReqAmount != 0 && !string.IsNullOrEmpty(TrnDate) && Amount != 0 && Status == 1)
                {
                    SendEmailRequest Request = new SendEmailRequest();
                    ApplicationUser  User    = new ApplicationUser();
                    User = await _userManager.FindByIdAsync(UserID);

                    if (!string.IsNullOrEmpty(User.Email))
                    {
                        IQueryable Result = await _messageConfiguration.GetTemplateConfigurationAsync(Convert.ToInt16(enCommunicationServiceType.Email), Convert.ToInt16(EnTemplateType.TransactionSuccess), 0);

                        foreach (TemplateMasterData Provider in Result)
                        {
                            Provider.Content = Provider.Content.Replace("###USERNAME###", User.Name);
                            Provider.Content = Provider.Content.Replace("###TYPE###", PairName);
                            Provider.Content = Provider.Content.Replace("###REQAMOUNT###", ReqAmount.ToString());
                            Provider.Content = Provider.Content.Replace("###STATUS###", "Success");
                            Provider.Content = Provider.Content.Replace("###USER###", User.Name);
                            Provider.Content = Provider.Content.Replace("###CURRENCY###", BaseMarket);
                            Provider.Content = Provider.Content.Replace("###DATETIME###", TrnDate);
                            Provider.Content = Provider.Content.Replace("###AMOUNT###", Amount.ToString());
                            Provider.Content = Provider.Content.Replace("###FEES###", Fees.ToString());
                            Provider.Content = Provider.Content.Replace("###FINAL###", (Amount + Fees).ToString());
                            Request.Body     = Provider.Content;
                            Request.Subject  = Provider.AdditionalInfo;
                        }
                        Request.Recepient = User.Email;
                        Request.EmailType = 0;
                        await _mediator.Send(Request);
                    }
                }
            }
            catch (Exception ex)
            {
                HelperForLog.WriteErrorLog("Settlement - EmailSendAsync Error ", ControllerName, ex);
            }
        }
        public async Task <IActionResult> EmailWithTemplateForSample([FromBody] SendEmailRequest Request)
        {
            try
            {
                string     GeneratedLink = "https://cleandevtest.azurewebsites.net/SSO_Account/api/SignUp/ConfirmEmail?emailConfirmCode=mLjgF4N8iwzW2z4fs7dUSmEgAO1M3GziSngzVkS2UV9JAk1SUnCUoinNXm3SjGmcFlA6Tqp7wJTShohQ89Snbx3aastoWzItNncfTqf9dGqUNPPaCWAyumi%2B3FbcG1Jrh%2F8eRPznAZ%2BXKrwNDWz3JSniADZ4eDRE4e9mKbTk9rmc3OieMKv7nsco43TFOdkqsEqis%2Bxj5dKoPGx%2Bsk%2FWQnuhTl3j7u%2FtByvBIGT3c3EwgbyIlTdO6hR5ZIMG1JwZwRQ7Tl6UjlJBFc3AGMTAI7aRWN0LZNTjqcSJ6UzpKZhHt5%2FKhF8qdtP13S0HnNnt%2B2rpBVpve9Aw4t1R9Wez0aQn38axHNQhBwBSgqnDg0I%3D";
                IQueryable Result        = await _messageConfiguration.GetTemplateConfigurationAsync(Convert.ToInt16(enCommunicationServiceType.Email), Convert.ToInt16(EnTemplateType.Registration), 0);

                foreach (TemplateMasterData Provider in Result)
                {
                    //string[] splitedarray = Provider.AdditionaInfo.Split(",");
                    //foreach (string s in splitedarray)
                    //{
                    Provider.Content = Provider.Content.Replace("#Link#", GeneratedLink);
                    Provider.Content = Provider.Content.Replace("###USERNAME###", "Khushali");
                    Provider.Content = Provider.Content.Replace("###TYPE###", "LTCBTC");
                    Provider.Content = Provider.Content.Replace("###REQAMOUNT###", "100000");
                    Provider.Content = Provider.Content.Replace("###STATUS###", "Success");
                    Provider.Content = Provider.Content.Replace("###USER###", "Khushali");
                    Provider.Content = Provider.Content.Replace("###CURRENCY###", "BTC");
                    Provider.Content = Provider.Content.Replace("###DATETIME###", "4 Nov 2018 12:39 PM");
                    Provider.Content = Provider.Content.Replace("###AMOUNT###", "100000");
                    Provider.Content = Provider.Content.Replace("###FEES###", "1000");
                    Provider.Content = Provider.Content.Replace("###FINAL###", "101000");
                    //}
                    Request.Body = Provider.Content;
                }

                CommunicationResponse Response = await _mediator.Send(Request);

                return(Ok(Response));
            }
            catch (Exception ex)
            {
                return(BadRequest(Response));
            }
        }
示例#3
0
        public async Task <OtpMasterViewModel> AddOtp(int UserId, string Email = null, string Mobile = null)
        {
            var checkotp = await GetOtpData(UserId);

            string OtpValue = string.Empty;

            if (checkotp != null)
            {
                UpdateOtp(checkotp.Id);
            }
            OtpValue = _userService.GenerateRandomOTPWithPassword().ToString();
            string alpha = string.Empty; string numeric = string.Empty;

            foreach (char str in OtpValue)
            {
                if (char.IsDigit(str))
                {
                    if (numeric.Length < 6)
                    {
                        numeric += str.ToString();
                    }
                    else
                    {
                        alpha += str.ToString();
                    }
                }
                else
                {
                    alpha += str.ToString();
                }
            }

            int Regtypeid = 0;

            if (!String.IsNullOrEmpty(Email))
            {
                Regtypeid = await _registerTypeService.GetRegisterId(Core.Enums.enRegisterType.Email);
            }
            else if (!String.IsNullOrEmpty(Mobile))
            {
                Regtypeid = await _registerTypeService.GetRegisterId(Core.Enums.enRegisterType.Mobile);
            }

            var currentotp = new OtpMaster
            {
                UserId      = UserId,
                RegTypeId   = Regtypeid,
                OTP         = numeric,
                CreatedTime = DateTime.UtcNow,
                ExpirTime   = DateTime.UtcNow.AddHours(2),
                Status      = 0,
                CreatedDate = DateTime.Now,
                CreatedBy   = UserId
            };

            _customRepository.Add(currentotp);

            if (!String.IsNullOrEmpty(Email))
            {
                SendEmailRequest request = new SendEmailRequest();
                request.Recepient = Email;
                // request.Subject = EnResponseMessage.LoginEmailSubject;
                // request.Body = EnResponseMessage.SendMailBody + numeric;



                IQueryable Result = await _messageConfiguration.GetTemplateConfigurationAsync(Convert.ToInt16(enCommunicationServiceType.Email), Convert.ToInt16(EnTemplateType.LoginWithOTP), 0);

                foreach (TemplateMasterData Provider in Result)
                {
                    Provider.Content = Provider.Content.Replace("###USERNAME###", string.Empty);
                    Provider.Content = Provider.Content.Replace("###Password###", numeric);
                    //string[] splitedarray = Provider.AdditionaInfo.Split(",");
                    //foreach (string s in splitedarray)
                    //{

                    //}
                    request.Body    = Provider.Content;
                    request.Subject = Provider.AdditionalInfo;
                }

                await _mediator.Send(request);
            }
            if (!String.IsNullOrEmpty(Mobile))
            {
                SendSMSRequest request = new SendSMSRequest();
                request.MobileNo = Convert.ToInt64(Mobile);
                request.Message  = EnResponseMessage.SendMailBody + numeric;
                await _mediator.Send(request);
            }

            string _Pass1   = alpha.Substring(0, 20);
            string _Pass11  = _Pass1 + numeric.Substring(0, 3);
            string _Pass2   = alpha.Substring(20, 10);
            string _Pass22  = _Pass2 + numeric.Substring(3, 3);
            string _Pass3   = alpha.Substring(30, 28);
            string password = _Pass11 + _Pass22 + _Pass3;

            OtpMasterViewModel model = new OtpMasterViewModel();

            if (currentotp != null)
            {
                model.UserId      = currentotp.UserId;
                model.RegTypeId   = currentotp.RegTypeId;
                model.OTP         = currentotp.OTP;
                model.CreatedTime = currentotp.CreatedTime;
                model.ExpirTime   = currentotp.ExpirTime;
                model.Status      = currentotp.Status;
                model.Id          = currentotp.Id;
                model.Password    = password;
                model.appkey      = alpha;
                return(model);
            }
            else
            {
                return(null);
            }
        }