Пример #1
0
        public ActionResult CreateEdit(LandingPage model, bool updateShortUrl = false, string publish = "")
        {
            var isNewEntry = model.Id == 0;

            if (ModelState.IsValid)
            {
                //ITransaction trans = CurrentSession.BeginTransaction();
                try
                {
                    model.Published = publish == "Publish" ? (DateTime?)DateTime.Now : null;

                    //CurrentSession.SaveOrUpdate(model);
                    //trans.Commit();

                    //var routeChange = false; //model.ShortUrl != null ? (isNewEntry || oldModel.ShortUrl != model.ShortUrl ? true : false) : false;
                    if (updateShortUrl)
                    {
                        //RouteConfig.RegisterShortRoute(model);
                    }

                    TempData["Message"] = (isNewEntry ? "Created" : "Updated") + " entry (#" + model.Id + ") " + model.Name;
                    return RedirectToAction("Index");
                }
                catch (Exception ex)
                {
                    //trans.Rollback();
                    TempData["Error"] = ex.ToString();
                }
            }

            ViewBag.UpdateMode = !isNewEntry;
            return View(model);
        }
Пример #2
0
        public virtual LandingPage CopyFromEdit(LandingPage m)
        {
            this.Name = m.Name;
            this.Created = m.Created;
            this.Published = m.Published;
            this.ShortUrl = m.ShortUrl;
            this.ShareDescription = m.ShareDescription;
            this.ShareImageUrl = m.ShareImageUrl;
            //foreach(var x in this.Panels)
            //    this.Panels.
            this.Panels = new List<LandingPagePanel>() {
                LandingPagePanel.Create(PanelType.Intro),
                LandingPagePanel.Create(PanelType.Picture),
                LandingPagePanel.Create(PanelType.Video),
                LandingPagePanel.Create(PanelType.Form),
                LandingPagePanel.Create(PanelType.Article)
            };

            return this;
        }