private ActionResult BindContactUsReport(ContactUsReportModel model)
        {
            try
            {
                model.PageNumber = model.PageNumber == null ? 1 : model.PageNumber;
            }
            catch { model.PageNumber = 1; }
            model.PageSize = Convert.ToInt32(StratasFair.Business.CommonHelper.CommonData.FetchSettingValue("Admin.PageSize.Long")); // 2

            return(View(model));
        }
        public ActionResult ContactUsExportToCsv()
        {
            try
            {
                ConvertToCSV objCSV = new ConvertToCSV();

                string FilePath = "~/Content/Resources/Reports/csvData.csv";
                objCSV.fncDeleteFile(FilePath);

                ReportsHelper        objLedgerHelper = new ReportsHelper();
                ContactUsReportModel objLedgerModel  = new ContactUsReportModel
                {
                    PageNumber = 1,
                    PageSize   = 100000000
                };

                List <ContactUsReportModel> listLedgerModel = objLedgerHelper.GetContactUsReport(objLedgerModel);

                DataTable dt = new DataTable();
                dt.Columns.Add("Name");
                dt.Columns.Add("Email Address");
                dt.Columns.Add("Message");
                dt.Columns.Add("Created On");


                if (listLedgerModel.Count() != 0)
                {
                    foreach (var item in listLedgerModel)
                    {
                        DataRow row = dt.NewRow();
                        row["Name"]          = item.FirstName;
                        row["Email Address"] = item.EmailAddress;
                        row["Message"]       = item.Message;
                        row["Created On"]    = StratasFair.Business.CommonHelper.AppLogic.GetDateFromatForCsv(item.CreatedOn);
                        dt.Rows.Add(row);
                    }
                }



                if (dt.Rows.Count > 0)
                {
                    objCSV.CreateCSVFile(dt, Server.MapPath("~/Content/Resources/Reports/") + "csvData.csv");

                    objCSV.FncDownLoadFiles("ContactUs_" + DateTime.Now.ToShortDateString() + ".csv", FilePath);
                }
            }
            catch (Exception Ex)
            {
                string Err = Ex.Message.ToString();
            }
            return(Redirect(Url.Content("~/securehost/rootlogin/report/contactus")));
        }
Beispiel #3
0
 /// <summary>
 /// Get the contact us query report
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public List <ContactUsReportModel> GetContactUsReport(ContactUsReportModel model)
 {
     return(context.Usp_ContactUsReportAdmin(model.KeywordSearch, model.PageNumber, model.PageSize).Select(x => new ContactUsReportModel
     {
         Sno = x.Sno,
         ContactUsId = x.ContactUsId,
         FirstName = x.FirstName,
         LastName = x.LastName,
         Message = x.Message,
         CreatedOn = x.CreatedOn,
         TotalCount = x.TotalCount.Value,
         Status = x.Status,
         EmailAddress = x.EmailAddress
     }).ToList());
 }
 public ActionResult ContactUs(ContactUsReportModel model, int?id)
 {
     model.PageNumber = 1;
     return(BindContactUsReport(model));
 }
 public ActionResult ContactUs(ContactUsReportModel model)
 {
     return(BindContactUsReport(model));
 }