/// <summary> /// Updates the status is show page static. /// </summary> /// <param name="id">The identifier.</param> /// <param name="status">The status.</param> /// <param name="type">The type.</param> /// <returns>update status is show page static</returns> public ActionResult Update_status_is_show_page_static(string id, string status, string type) { PageModels pageModels = new PageModels(); C_Pages cpage = new C_Pages(); bool isOk = false; if (UserModels.CheckPermission(this.Session["mem"] != null ? this.Session["mem"].ToString() : string.Empty, "change_static", "adminStatic", CommonGlobal.Edit, type)) { isOk = true; } else { isOk = false; } if (!string.IsNullOrEmpty(id)) { if (int.Parse(id) > 0) { cpage = pageModels.GetbyID(int.Parse(id)); } if (cpage != null) { try { if (bool.Parse(status) == true) { cpage.Show = true; } else { cpage.Show = false; } if (isOk) { cpage.DateModified = DateTime.Now; pageModels.Edit(cpage); } } catch (Exception) { } } } var jsonSerialiser = new JavaScriptSerializer(); var results = Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy") + "|" + cpage.Show; return(this.Json(results)); }
public ActionResult Change_static(FormCollection collection) { PageModels pageModels = new PageModels(); C_Pages cpage = new C_Pages(); StringBuilder sb = new StringBuilder(); var page_view = new Web.Areas.Admin.ViewModels.Page_view(); this.TryUpdateModel(page_view); int rt = 0; bool is_valid = true; if (page_view.Id > 0) { cpage = pageModels.GetbyID(page_view.Id); } ////validation server if (string.IsNullOrEmpty(page_view.PageName)) { is_valid = false; if (page_view.Message != string.Empty) { page_view.Message = "Bạn cần nhập Tên trang"; } } if (string.IsNullOrEmpty(page_view.PageContent)) { is_valid = false; if (page_view.Message != string.Empty) { page_view.Message = "Bạn cần nhập nội dung trang tĩnh"; } } ////Link tab sb.Append("<li><a href=\"" + Url.Action("index", "dashboard", new { act = "list_page_static", ctrl = "adminStatic", page = "1" }) + "\"><span><span>Danh sách trang tĩnh</span></span></a></li>"); if (page_view.Id != 0 && page_view.Type_act == CommonGlobal.Edit) { sb.Append("<li class=\"active\"><a href=\"#\"><span><span>" + cpage.PageName + "</span></span></a></li>"); page_view.List_language = this.List_select_language(cpage.Lang); page_view.Id = cpage.PageID; } else { sb.Append("<li class=\"active\"><a href=\"#\"><span><span>Thêm trang tĩnh</span></span></a></li>"); page_view.List_language = this.List_select_language(page_view.Lang); } page_view.Html_link_tab = sb.ToString(); ////action page_view.Parent_action = HttpContext.Request.RequestContext.RouteData.Values["action"].ToString(); page_view.Parent_controller = HttpContext.Request.RequestContext.RouteData.Values["controller"].ToString(); if (!is_valid) { return(this.PartialView("../control/change_static", page_view)); } cpage.Summary = string.IsNullOrEmpty(page_view.Summary) == false ? page_view.Summary : string.Empty; cpage.PageContent = string.IsNullOrEmpty(page_view.PageContent) == false ? page_view.PageContent : string.Empty; cpage.Lang = page_view.Lang; cpage.PageName = page_view.PageName; if (string.IsNullOrEmpty(page_view.Title)) { cpage.Title = page_view.PageName; } else { cpage.Title = page_view.Title; } cpage.Keyword = string.IsNullOrEmpty(page_view.Keyword) == false ? page_view.Keyword : string.Empty; cpage.Description = string.IsNullOrEmpty(page_view.Description) == false ? page_view.Description : string.Empty; cpage.Show = page_view.Show; if ((cpage.Show ?? false) == true) { page_view.Show = true; page_view.Show_text = "checked='checked'"; } else { page_view.Show = false; page_view.Show_text = string.Empty; } cpage.Link = CommonGlobal.CompleteLink(page_view.PageName); cpage.DateModified = DateTime.Now; var imgPathTemp = "images/static/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString() + "/"; var name_time = DateTime.Now.Day + DateTime.Now.Month + DateTime.Now.Year + DateTime.Now.Hour + DateTime.Now.Minute + string.Empty; if (page_view.File_image != null && page_view.File_image.ContentLength > 0 && CommonGlobal.IsImage(page_view.File_image) == true) { string image_small = imgPathTemp + "sc_small_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(page_view.File_image.FileName); string image_lager = imgPathTemp + "sc_full_" + name_time + "_" + CommonGlobal.CompleteNamefileImages(page_view.File_image.FileName); ////save image and delete old file this.Savephoto(cpage.ImagePath, page_view.File_image, imgPathTemp, image_small, image_lager); ////set image thumb to link catalog cpage.ImagePath = "/" + image_small; page_view.ImagePath = "/" + image_small; } else if (string.IsNullOrEmpty(cpage.ImagePath)) { cpage.ImagePath = "0"; } else { cpage.ImagePath = page_view.ImagePath; } cpage.OrderDisplay = page_view.OrderDisplay; if (page_view.Id != 0 && page_view.Type_act == CommonGlobal.Edit) { rt = pageModels.Edit(cpage); } else { rt = pageModels.Add(cpage); } if (rt > 0) { page_view.Message = "Cập nhật thành công!"; page_view.Id = rt; page_view.Type_act = CommonGlobal.Edit; } else { page_view.Message = "Cập nhật không thành công!"; } return(this.PartialView("../control/change_static", page_view)); }