public List <CLayer.StaticPage> GetAllWidget() { DataTable dt = Connection.GetTable("staticpage_GetAllForWidget"); List <CLayer.StaticPage> result = new List <CLayer.StaticPage>(); CLayer.StaticPage t; foreach (DataRow dr in dt.Rows) { t = new CLayer.StaticPage(); t.PageId = Connection.ToLong(dr["PageId"]); t.City = Connection.ToString(dr["City"]); t.Location = Connection.ToString(dr["Location"]); // t.PageTitle = Connection.ToString(dr["PageTitle"]); t.Image = Connection.ToString(dr["Image"]); t.RootFolder = Connection.ToString(dr["RootFolder"]); t.Description = Connection.ToString(dr["Description"]); t.Description = CLayer.HtmlRemoval.StripTagsRegex(t.Description); if (t.Description.Length > 100) { t.Description = t.Description.Substring(0, 100) + ".."; } // tm = Connection.ToDate(dr["LastUpdate"]); // if (tm == DateTime.Now) // t.LastUpdate = ""; // else // t.LastUpdate = tm.ToShortDateString(); result.Add(t); } return(result); }
public ActionResult Delete(long?PageId) { try { string fileName = ""; CLayer.StaticPage dt = BLayer.StaticPage.GetPage(PageId.Value); Models.StaticPageModel data = new Models.StaticPageModel(); data.Image = dt.Image; data.RootFolder = dt.RootFolder; data.FileName = dt.FileName; fileName = System.IO.Path.GetFileName(dt.Image); if (System.IO.Directory.Exists(Server.MapPath("~/Files/SEO/"))) { var path1 = System.IO.Path.Combine(Server.MapPath("~/Files/SEO/"), fileName); if (System.IO.File.Exists(path1)) { System.IO.File.Delete(path1); } } var path3 = System.IO.Path.Combine(Server.MapPath("~/" + dt.RootFolder), dt.FileName); if (System.IO.File.Exists(path3)) { System.IO.File.Delete(path3); } BLayer.StaticPage.Delete(PageId.Value); } catch (Exception ex) { Common.LogHandler.HandleError(ex); } return(RedirectToAction("Index")); }
public List <CLayer.StaticPage> GetAll() { string sql = "Select * From staticpage"; DataTable dt = Connection.GetSQLTable(sql); List <CLayer.StaticPage> result = new List <CLayer.StaticPage>(); CLayer.StaticPage t; DateTime tm; foreach (DataRow dr in dt.Rows) { t = new CLayer.StaticPage(); t.PageId = Connection.ToLong(dr["PageId"]); t.City = Connection.ToString(dr["City"]); t.Location = Connection.ToString(dr["Location"]); t.PageTitle = Connection.ToString(dr["PageTitle"]); tm = Connection.ToDate(dr["LastUpdate"]); if (tm == DateTime.Now) { t.LastUpdate = ""; } else { t.LastUpdate = tm.ToShortDateString(); } //t.City = Connection.ToString(dr["City"]); //t.City = Connection.ToString(dr["City"]); //t.City = Connection.ToString(dr["City"]); //t.City = Connection.ToString(dr["City"]); result.Add(t); } return(result); }
public long SaveProperty(CLayer.StaticPage data) { List <DataPlug.Parameter> param = new List <DataPlug.Parameter>(); param.Add(Connection.GetParameter("pPageId", DataPlug.DataType._BigInt, data.PageId)); param.Add(Connection.GetParameter("pPropertyId", DataPlug.DataType._Varchar, data.PropertyId)); object obj = Connection.ExecuteQueryScalar("staticpageProperty_Save", param); return(Connection.ToLong(obj)); }
public ActionResult ClearFile(string ClrPIds) { string[] s = ClrPIds.Split(','); foreach (string PageId in s) { long id = Convert.ToInt32(PageId); CLayer.StaticPage dt = BLayer.StaticPage.GetPage(id); var path4 = System.IO.Path.Combine(Server.MapPath("~/" + dt.RootFolder), dt.FileName); if (System.IO.File.Exists(path4)) { System.IO.File.Delete(path4); } } return(RedirectToAction("Index")); }
public async Task <ActionResult> Remove(long PropertyId, long PageId, string Destination, Models.StaticHtmlPageModel model) { try { CLayer.StaticPage dt = BLayer.StaticPage.GetPage(PageId); BLayer.StaticPage.RemoveStaticProperty(PropertyId); model.PageTitle = dt.PageTitle; model.Destination = Destination; model.City = Destination; return(await Search(model)); } catch (Exception ex) { Common.LogHandler.HandleError(ex); return(Redirect("~/ErrorPage")); } }
public ActionResult Index(long PageId) { Models.StaticHtmlPageModel data = new Models.StaticHtmlPageModel(); data.PageId = PageId; CLayer.StaticPage obj = BLayer.StaticPage.GetPage(PageId); List <CLayer.SearchResult> dtlist1 = BLayer.Property.GetStaticPagePrpty(PageId); data.PropertyList = dtlist1; string url = Request.Url.AbsoluteUri; data.PageTitle = obj.PageTitle; data.Description = obj.Description; data.Image = obj.Image; data.ShowInWidget = obj.ShowInWidget; data.Location = obj.Location; data.City = obj.City; return(View(data)); }
public async Task <ActionResult> AddProperty(IEnumerable <int> Propertyselected, Models.StaticHtmlPageModel model) { long PageId = model.PageId; if (Propertyselected != null) { foreach (var PropertyId in Propertyselected) { CLayer.StaticPage dt = new CLayer.StaticPage(); dt.PropertyId = PropertyId; dt.PageId = PageId; BLayer.StaticPage.SaveProperty(dt); } } return(await Search(model)); //return RedirectToAction("Index", new { PageId = model.PageId }); }
public ActionResult EditPage(long Id) { Models.StaticPageModel data = new Models.StaticPageModel(); data.PageId = Id; CLayer.StaticPage dt = BLayer.StaticPage.GetPage(Id); if (dt == null) { return(RedirectToAction("NewPage")); } data.PageTitle = dt.PageTitle; data.Description = dt.Description; data.FileName = dt.FileName; data.ShowInWidget = dt.ShowInWidget; data.Location = dt.Location; data.City = dt.City; data.Image = dt.Image; data.RootFolder = dt.RootFolder; return(View("_Edit", data)); }
public long Save(CLayer.StaticPage data) { List <DataPlug.Parameter> param = new List <DataPlug.Parameter>(); param.Add(Connection.GetParameter("pPageId", DataPlug.DataType._BigInt, data.PageId)); param.Add(Connection.GetParameter("pCity", DataPlug.DataType._Varchar, data.City)); param.Add(Connection.GetParameter("pLocation", DataPlug.DataType._Varchar, data.Location)); param.Add(Connection.GetParameter("pImage", DataPlug.DataType._Varchar, data.Image)); param.Add(Connection.GetParameter("pFilename", DataPlug.DataType._Varchar, data.FileName)); param.Add(Connection.GetParameter("pDescription", DataPlug.DataType._Varchar, data.Description)); param.Add(Connection.GetParameter("pShowInWidget", DataPlug.DataType._Bool, data.ShowInWidget)); param.Add(Connection.GetParameter("pRootFolder", DataPlug.DataType._Varchar, data.RootFolder)); param.Add(Connection.GetParameter("pPageTitle", DataPlug.DataType._Varchar, data.PageTitle)); object obj = Connection.ExecuteQueryScalar("staticpage_Save", param); return(Connection.ToLong(obj)); // B2 //staticpage_Save // pDescription VARCHAR(3000),pShownInWidget BOOL,pRootFolder VARCHAR(255),pPageTitle VARCHAR(500) }
// // GET: /Admin/PropertyAdd/ public async Task <ActionResult> Index(long PageId) { Models.StaticHtmlPageModel data = new Models.StaticHtmlPageModel(); data.PageId = PageId; CLayer.StaticPage dt = BLayer.StaticPage.GetPage(PageId); data.PageTitle = dt.PageTitle; data.Location = dt.Location; data.City = dt.City; data.PageTitle = dt.PageTitle; data.Destination = dt.City; List <CLayer.SearchResult> dtlist1 = BLayer.Property.GetAllPrptyStatic(); SearchResults result = await SearchFilter(data); data.PropertyList = result.Results; List <CLayer.SearchResult> dtlist2 = BLayer.Property.GetStaticPagePrpty(PageId); data.MaxCount = result.TotalRows; data.PropertyAdd = dtlist2; data.MaxCount = result.TotalRows; data.CurrentPage = 1; return(View(data)); }
public CLayer.StaticPage GetPage(long pageId) { string sql = "Select * From staticpage Where PageId=" + pageId.ToString(); DataTable dt = Connection.GetSQLTable(sql); CLayer.StaticPage result = null; if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; result = new CLayer.StaticPage(); result.PageId = Connection.ToLong(dr["PageId"]); result.City = Connection.ToString(dr["City"]); result.Location = Connection.ToString(dr["Location"]); result.PageTitle = Connection.ToString(dr["PageTitle"]); result.Description = Connection.ToString(dr["Description"]); result.FileName = Connection.ToString(dr["FileName"]); result.Image = Connection.ToString(dr["Image"]); result.ShowInWidget = Connection.ToBoolean(dr["ShowInWidget"]); result.RootFolder = Connection.ToString(dr["RootFolder"]); } return(result); }
public ActionResult Save(Models.StaticPageModel data) { try { CLayer.StaticPage sp = new CLayer.StaticPage(); string fileName = ""; if (data.ImageFile != null && data.ImageFile.ContentLength > 0) { int Sizevalue = Convert.ToInt32(ConfigurationManager.AppSettings.Get("FileUploadSizeInMB")); int MaxContentLength = 1024 * 1024 * Sizevalue; //3 MB string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".jpeg" }; if (!AllowedFileExtensions.Contains(data.ImageFile.FileName.Substring(data.ImageFile.FileName.LastIndexOf('.')))) { ModelState.AddModelError(string.Empty, "Please use files of type: " + string.Join(", ", AllowedFileExtensions)); return(View("_Edit", data)); } else if (data.ImageFile.ContentLength > MaxContentLength) { ModelState.AddModelError(string.Empty, "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB"); return(View("_Edit", data)); } else { fileName = System.IO.Path.GetFileName(data.ImageFile.FileName); //uploaded file from UI if (!System.IO.Directory.Exists(Server.MapPath("~/Files/Temp/"))) { System.IO.Directory.CreateDirectory(Server.MapPath("~/Files/Temp/")); } //System.IO.Directory.CreateDirectory(Server.MapPath("~/Files/Temp/"+ data.RootFolder +"/")); var path = System.IO.Path.Combine(Server.MapPath("~/Files/Temp/"), fileName); data.ImageFile.SaveAs(path); int maxHeight = Convert.ToInt32(ConfigurationManager.AppSettings.Get("MaxImgHeight")); Image tempimage = Image.FromFile(path); Image resized = Common.Utils.ScaleImage(tempimage, maxHeight); if (!System.IO.Directory.Exists(Server.MapPath("~/Files/SEO/"))) { System.IO.Directory.CreateDirectory(Server.MapPath("~/Files/SEO/")); } var path2 = System.IO.Path.Combine(Server.MapPath("~/Files/SEO/"), fileName); //ImageCodecInfo //System.Drawing.Imaging.ImageCodecInfo jgpEncoder = GetEncoder(System.Drawing.Imaging.ImageFormat.Jpeg); //System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality; //System.Drawing.Imaging.EncoderParameters myEncoderParameters = new System.Drawing.Imaging.EncoderParameters(); //System.Drawing.Imaging.EncoderParameter myEncoderParameter = new System.Drawing.Imaging.EncoderParameter(myEncoder,50L); //myEncoderParameters.Param[0] = myEncoderParameter; resized.Save(path2, System.Drawing.Imaging.ImageFormat.Jpeg); try { resized.Dispose(); tempimage.Dispose(); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } catch { } } //else part } //image file check if (data.PageId > 0) { if (fileName == "") { CLayer.StaticPage ss = BLayer.StaticPage.GetPage(data.PageId); fileName = ss.Image; } }//update call sp.Image = fileName; sp.PageId = data.PageId; sp.PageTitle = data.PageTitle; sp.RootFolder = FixPath(data.RootFolder); sp.ShowInWidget = data.ShowInWidget; sp.Location = data.Location; sp.Description = data.Description; sp.City = data.City; sp.FileName = FixFile(data.FileName); BLayer.StaticPage.Save(sp); } catch (Exception ex) { Common.LogHandler.HandleError(ex); } return(RedirectToAction("Index")); }
public static long SaveProperty(CLayer.StaticPage data) { DataLayer.StaticPage st = new DataLayer.StaticPage(); return(st.SaveProperty(data)); }