public JsonResult LoadContact() { String searc = Request.QueryString["search[value]"]; var repo = new Repository<ContactMarkettingModel>("contactMarketting"); var datax = repo.Gets().Select(i => new { name = i.Name, objecttitle = i.ObjectTitle, tel = i.Tel, email = i.Email, date = i.date }); JsonPage page=new JsonPage(); String pageindex= Request.QueryString["draw"]; int pagesize = 10; page.recordsTotal = datax.ToList().Count; page.recordsFiltered = datax.ToList().Count; page.draw = int.Parse(pageindex); String lg = Request.QueryString["length"]; String begin = Request.QueryString["start"]; datax = datax.Skip(int.Parse(begin)).Take(int.Parse(lg)); page.data = datax; var data = Json(page, JsonRequestBehavior.AllowGet); return data; }
public async Task<JsonResult> Post(ContactMarkettingModel model) { //validate data if (!ModelState.IsValid) return Json(false); #region log it var log = log4net.LogManager.GetLogger("mbnd"); log.Info(JsonConvert.SerializeObject(model, Formatting.Indented)); #endregion #region storeDb var repo = new Repository<ContactMarkettingModel>("contactMarketting"); var data = repo.Gets().Where(i => i.Email == model.Email).ToList(); if (data.Count>0) { JsonPage page = new JsonPage(); page.T = 1; return Json(page,JsonRequestBehavior.AllowGet); } else { repo.Insert(model); } #endregion #region Send Email //try //{ // if (!String.IsNullOrEmpty(model.EmailCustomer)) // { // var mMess = new MailMessage // { // From = new MailAddress(ConfigurationManager.AppSettings["Gmail"]) // }; // mMess.To.Add(new MailAddress(model.EmailCustomer)); // mMess.Subject = "Lead muabannhadat.vn " + model.Name; // mMess.IsBodyHtml = true; // mMess.Body = RenderRazorViewToString("TemplateEmail", model); // var smClt = new SmtpClient {EnableSsl = true}; // smClt.Send(mMess); // return Json(true); // } //} //catch //{ // return Json(false); //} #endregion return Json(true); }