public Dictionary <string, object> ViewAllAutoReportRequest(JsonFields Data)
        {
            var Result = Common.Getdata(dbcontext.MultipleResults("[dbo].[FAMS_AutoReportRequest]").With <ViewAllAutoReportRequest>().Execute("@QueryType", "@CustomerAccount", "ViewAllAutoReportRequest", Data.CustomerAccount));

            return(Result);
        }
        public Dictionary <string, object> SendMailAllAutoReportRequest(JsonFields Data)
        {
            List <SendMailAllAutoReportRequest> Gridlist = new List <SendMailAllAutoReportRequest>();
            var Result = dbcontext.MultipleResults("[dbo].[FAMS_AutoReportRequest]").With <SendMailAllAutoReportRequest>().Execute("@QueryType", "@CustomerAccount", "SendMailAllAutoReportRequest", Data.CustomerAccount);

            Gridlist = Result[0].Cast <SendMailAllAutoReportRequest>().ToList();
            DataTable dt = new DataTable();

            dt = ToDataTable(Gridlist);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                //var EmailId = "*****@*****.**";
                var EmailId      = dt.Rows[i]["EmailId"].ToString();
                var UserName     = dt.Rows[i]["UserName"].ToString();
                var AccountNo    = dt.Rows[i]["AccountNo"].ToString();
                var DownloadLink = dt.Rows[i]["DownloadLink"].ToString();

                using (StringWriter sw = new StringWriter())
                {
                    using (HtmlTextWriter hw = new HtmlTextWriter(sw))
                    {
                        StringBuilder sb            = new StringBuilder();
                        string        WebAppUrl     = ConfigurationManager.AppSettings["WebAppUrl"].ToString();
                        string        SMTPHost      = ConfigurationManager.AppSettings["SMTPHost"].ToString();
                        string        FromMailId    = ConfigurationManager.AppSettings["UserId"].ToString();
                        string        MailPassword  = ConfigurationManager.AppSettings["MailPassword"].ToString();
                        string        SMTPPort      = ConfigurationManager.AppSettings["SMTPPort"].ToString();
                        string        SMTPEnableSsl = ConfigurationManager.AppSettings["SMTPEnableSsl"].ToString();
                        sb.Append("Dear " + UserName + ",<br> <br>");
                        sb.Append("Please find attached pdf for your reference. <br> <br>");
                        // string User = HttpContext.Current.Server.UrlEncode(Dbsecurity.Encrypt(dataList1.Cast<UserDetails>().ToList().Select(x => x.UserId).First().ToString()));
                        // sb.Append("<a href=' " + WebAppUrl + "ChangePassword/" + User + "' target='_blank'>");
                        //sb.Append("<input style='background-color: #3965a9;color: #fff;padding: 3px 10px 3px 10px;' type='button' value='Change Password' /></a> </div>");

                        sb.Append("Sincerely,<br>");
                        sb.Append("Yoeki Support Team <br> <br>");

                        SmtpClient  smtpClient  = new SmtpClient();
                        MailMessage mailmsg     = new MailMessage();
                        MailAddress mailaddress = new MailAddress(FromMailId);
                        mailmsg.To.Add(EmailId);
                        mailmsg.From = mailaddress;

                        mailmsg.Subject    = "All Auto Request : " + DownloadLink;
                        mailmsg.IsBodyHtml = true;
                        mailmsg.Body       = sb.ToString();


                        System.Net.Mail.Attachment attachment;
                        //attachment = new System.Net.Mail.Attachment(ConfigurationManager.AppSettings["ExcelFilePath"] + "\\" + ConfigurationManager.AppSettings["ExcelFileName"]);
                        // attachment = new System.Net.Mail.Attachment(ConfigurationManager.AppSettings["ExcelFilePath"] + DownloadLink);
                        attachment = new System.Net.Mail.Attachment(HttpContext.Current.Server.MapPath(DownloadLink).Replace("\\api\\AutoReportRequest", ""));

                        //HttpContext.Current.Server.MapPath("Customerwisedata/3/6010001/6010001_30-06-2020.pdf")
                        //attachment = new System.Net.Mail.Attachment(ConfigurationManager.AppSettings["ExcelFilePath"] + "Customerwisedata\\4\\6010001\\6010001_30-06-2020.pdf");
                        attachment.Name = DownloadLink;//ConfigurationManager.AppSettings["ExcelFileName"];
                        mailmsg.Attachments.Add(attachment);


                        smtpClient.Host                  = SMTPHost;
                        smtpClient.Port                  = Convert.ToInt32(SMTPPort);
                        smtpClient.EnableSsl             = Convert.ToBoolean(SMTPEnableSsl);
                        smtpClient.UseDefaultCredentials = true;
                        smtpClient.Credentials           = new System.Net.NetworkCredential(FromMailId, MailPassword);
                        smtpClient.Send(mailmsg);
                        //QuickCheck_AngularEntities dbcontext = new QuickCheck_AngularEntities();
                        //dbcontext.MultipleResults("[dbo].[Sp_SendEmail]").With<Responsevalue>().Execute("@QueryType", "@MandateId", "@EmailCount", "@SmsCount", "SendMail", Convert.ToString(0), "1", "0");

                        //emailobect.Flag = "1";
                        //emailobect.FlagValue = "Email sent successfully!!";
                        //common.Add(emailobect);
                    }
                }
            }

            Dictionary <string, object> d = new Dictionary <string, object>();

            d.Add("Success", "1");
            return(d);
            //return Result;
        }