예제 #1
0
 public ActionResult Delete(int?id, FormCollection collection)
 {
     try
     {
         CustomPageRepository ml = new CustomPageRepository();
         if (id != null && id > 0)
         {
             ml.Delete(id ?? 0);
         }
         else
         {
             if (string.IsNullOrEmpty(collection["IDs"]))
             {
                 return(Content("未指定删除对象ID"));
             }
             string[] ids = collection["IDs"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
             foreach (string item in ids)
             {
                 ml.Delete(int.Parse(item));
             }
         }
         return(Content("1"));
     }
     catch (Exception ex)
     {
         return(Content(ErrorWirter(RouteData, ex.Message)));
     }
 }
예제 #2
0
        public CustomPage GetCustomPage(string url)
        {
            List<QueryParameter> parameters = new List<QueryParameter>();
            parameters.Add(new QueryParameter("url", url));

            List<CustomPage> customPages = new CustomPageRepository().GetByParameter("getByUrl", parameters);
            return customPages.Count > 0 ? customPages[0] : null;
        }
예제 #3
0
 public int Save(BE.CustomPage custompage)
 {
     CustomPageRepository repository = new CustomPageRepository();
     if (custompage.ID > 0)
     {
         repository.Update(custompage);
         return custompage.ID;
     }
     else
         return repository.Insert(custompage);
 }
예제 #4
0
        public ActionResult GetContent(int id)
        {
            string EditContent = "";

            try
            {
                if (id > 0)
                {
                    EditContent = new CustomPageRepository().GetCustomPage(id).EditContent;
                }
            }
            catch { }
            return(Content(EditContent));
        }
예제 #5
0
        /// <summary>
        /// LayoutIt布局页面
        /// </summary>
        /// <returns></returns>
        public ActionResult LayoutIt(int?id)
        {
            CustomPage ct = new CustomPage();

            try
            {
                if (id != null && id > 0)
                {
                    ct = new CustomPageRepository().GetCustomPage(id ?? 0);
                }
            }
            catch { }
            return(View(ct));
        }
예제 #6
0
        public ActionResult Edit(int id)
        {
            try
            {
                CustomPageRepository ml = new CustomPageRepository();

                CustomPage obj = ml.GetCustomPage(id);

                return(View(obj));
            }
            catch (Exception ex)
            {
                return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
            }
        }
예제 #7
0
 //[HttpPost]
 public ActionResult CreateFile(int ajaxId, int ajaxType, string ajaxController, string ajaxAction, string ajaxEditcontent, string ajaxViewContent)
 {
     try
     {
         var path = Server.MapPath("~/") + "Views\\" + ajaxController + "\\" + ajaxAction + ".cshtml";
         if (ajaxType == 0)
         {
             path = Server.MapPath("~/") + "Views\\Shared\\" + ajaxAction + ".cshtml";
         }
         CustomPage           ct = new CustomPage();
         CustomPageRepository cc = new CustomPageRepository();
         if (ajaxId != 0)
         {
             ct                  = cc.GetCustomPage(ajaxId);
             ct.Type             = ajaxType;
             ct.Controller       = ajaxController;
             ct.Action           = ajaxAction;
             ct.Path             = path;
             ct.EditContent      = ajaxEditcontent;
             ct.LastUpdateDate   = DateTime.Now;
             ct.LastUpdateUserID = ID;
             cc.Update(ct);
         }
         else
         {
             ct.Type             = ajaxType;
             ct.Controller       = ajaxController;
             ct.Action           = ajaxAction;
             ct.Path             = path;
             ct.EditContent      = ajaxEditcontent;
             ct.CreateDate       = DateTime.Now;
             ct.CreateUserID     = ID;
             ct.LastUpdateDate   = DateTime.Now;
             ct.LastUpdateUserID = ID;
             ct.IsDeleted        = false;
             cc.Insert(ct);
         }
         string htmlcontent = "@{\r\n    ViewBag.Title = \"" + ajaxAction + "\";\r\n    Layout = \"~/Views/Shared/_Layout.cshtml\";\r\n}";
         htmlcontent += ajaxViewContent;
         Common.FileHelper.WriteFile(path, htmlcontent);
         return(Content("1"));
     }
     catch { }
     return(Content("0"));
 }
예제 #8
0
 public ActionResult Index(int?pageIndex, int?pageSize)
 {
     try
     {
         CustomPageRepository ml = new CustomPageRepository();
         var entity = new CustomPage();
         entity.IsDeleted = false;
         PagedList <CustomPage> page = ml.Search(entity).GetPagedList(pageIndex ?? PageIndex, pageSize ?? PageSize, Order, By);
         if (Request.IsAjaxRequest())
         {
             return(PartialView("_Index", page));
         }
         return(View(page));
     }
     catch (Exception ex)
     {
         return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
     }
 }
예제 #9
0
 public ActionResult Delete(int id)
 {
     try
     {
         CustomPageRepository ml = new CustomPageRepository();
         if (id > 0)
         {
             ml.Delete(id);
         }
         else
         {
             return(Content("未指定删除对象ID"));
         }
         return(Content("1"));
     }
     catch (Exception ex)
     {
         return(Content(ErrorWirter(RouteData, ex.Message)));
     }
 }
예제 #10
0
        public ActionResult Edit(CustomPage obj, FormCollection formCollection)
        {
            try
            {
                CustomPageRepository ml = new CustomPageRepository();

                obj.LastUpdateDate = DateTime.Now;

                obj.LastUpdateUserID = ID;

                UpdateModel(obj);

                bool result = ml.Update(obj) > 0 ? true : false;

                return(result ? Content(ContentIcon.Succeed + "|操作成功") : Content(ContentIcon.Error + "|操作失败"));
            }
            catch (Exception ex)
            {
                return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
            }
        }
예제 #11
0
        public ActionResult Create(FormCollection formCollection)
        {
            try
            {
                CustomPageRepository ml = new CustomPageRepository();

                CustomPage obj = new CustomPage()
                {
                    CreateDate = DateTime.Now, CreateUserID = ID, IsDeleted = false
                };

                UpdateModel(obj);

                bool result = ml.Insert(obj) > 0 ? true : false;

                return(result ? Content(ContentIcon.Succeed + "|操作成功|/admin/CustomPage/Index") : Content(ContentIcon.Error + "|操作失败"));
            }
            catch (Exception ex)
            {
                return(Content(ContentIcon.Error + "|" + ErrorWirter(RouteData, ex.Message)));
            }
        }