private int Insert(tbl_Orders order) { try { db.tbl_Orders.Add(order); db.SaveChanges(); return(order.Id); } catch (Exception ex) { Console.Write(ex); throw; } }
public ActionResult CreateTour([Bind(Include = "Id,TenTourEN,TenTourTL,TenTourVN,DonGia,DonViTinh,NgayKhoiHanh,NgayKetThuc,SoNgay,SoDem,SoCho,NoiDungEN,NoiDungTL,NoiDungVN,HinhAnh,KhuyenMai,TourHot,NgayTao,Language,CategoryId")] tbl_Tour tbl_Tour) { if (ModelState.IsValid) { db.tbl_Tour.Add(tbl_Tour); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_Tour)); }
public ActionResult ContactResult([Bind(Include = "Id,Ho,Ten,Email,TenCongTy,DiaChi,SoDT,GhiChu")] tbl_Contact tbl_Contact) { if (ModelState.IsValid) { var admin = db.tbl_Account.Where(x => x.IsAdmin).ToList().FirstOrDefault(); db.tbl_Contact.Add(tbl_Contact); db.SaveChanges(); try { //send admin string content = System.IO.File.ReadAllText(Server.MapPath("~/Views/ContactMail/ContactCustomSendAdmin.cshtml")); content = content.Replace("{{TenKH}}", tbl_Contact.Ho + " " + tbl_Contact.Ten); content = content.Replace("{{SoDT}}", tbl_Contact.SoDT); content = content.Replace("{{Email}}", tbl_Contact.Email); content = content.Replace("{{DiaChi}}", tbl_Contact.DiaChi); content = content.Replace("{{TenCompany}}", tbl_Contact.TenCongTy); content = content.Replace("{{Comment}}", tbl_Contact.GhiChu); if (admin != null) { string contentCusstom = null; if (CommonConstants.CurrentCulture == null) { contentCusstom = System.IO.File.ReadAllText(Server.MapPath("~/Views/ContactMail/ContactCustom.cshtml")); new MailHelper().SendMail(tbl_Contact.Email, Resource.lblConfigFromEmailDisplayNameContact, null, contentCusstom, true, true); } else if (CommonConstants.CurrentCulture.Equals("vi")) { contentCusstom = System.IO.File.ReadAllText(Server.MapPath("~/Views/ContactMail/ContactCustom_vi.cshtml")); new MailHelper().SendMail(tbl_Contact.Email, Resource.lblConfigFromEmailDisplayNameContact, null, contentCusstom, true, true); } else { contentCusstom = System.IO.File.ReadAllText(Server.MapPath("~/Views/ContactMail/ContactCustom_en.cshtml")); new MailHelper().SendMail(tbl_Contact.Email, Resource.lblConfigFromEmailDisplayNameContact, null, contentCusstom, true, true); } new MailHelper().SendMail(admin.Email, "Liên hệ từ khách hàng ", tbl_Contact.Ho + " " + tbl_Contact.Ten, content, true, false); Session[CommonConstants.CardSession] = null; return(RedirectToAction("SendContactSuccess")); } } catch (Exception ex) { return(RedirectToAction("SendContactError")); } return(RedirectToAction("SendContactError")); } return(View("Contact")); }