Beispiel #1
0
 /// <summary>
 /// Gets the edit model for the comment with the given id.
 /// </summary>
 /// <param name="id">The comment id.</param>
 /// <returns></returns>
 public static SiteTreeEditModel GetById(Guid id)
 {
     using (var db = new DataContext()) {
         var site  = db.SiteTrees.Where(s => s.Id == id).Single();
         var model = new SiteTreeEditModel(site.NamespaceId)
         {
             Id              = site.Id,
             InternalId      = site.InternalId,
             Name            = site.Name,
             NamespaceId     = site.NamespaceId,
             HostNames       = site.HostNames,
             Description     = site.Description,
             MetaTitle       = site.MetaTitle,
             MetaDescription = site.MetaDescription,
             CanDelete       = db.PageDrafts.Where(p => p.SiteTreeId == site.Id && (!p.ParentId.HasValue || p.ParentId.Value != site.Id)).Count() == 0,
             Template        = db.PageTemplates.Include(pt => pt.RegionTemplates).Where(pt => pt.Id == site.Id && pt.IsSiteTemplate).SingleOrDefault()
         };
         if (model.Template == null)
         {
             model.Template = new PageTemplate()
             {
                 Id             = site.Id,
                 Name           = site.Id.ToString(),
                 IsSiteTemplate = true
             };
         }
         else
         {
             model.Template.RegionTemplates = model.Template.RegionTemplates.OrderBy(r => r.Seqno).ToList();
         }
         model.Regions = model.Template.RegionTemplates;
         return(model);
     }
 }
		public ActionResult Edit(SiteTreeEditModel m) {
			if (ModelState.IsValid) {
				if (m.Save()) {
					ViewBag.Title = Resources.SiteTree.EditTitleExisting;
					SuccessMessage(Resources.SiteTree.MessageSaved);
					ModelState.Clear();
				} else {
					if (m.Id == Guid.Empty)
						ViewBag.Title = Resources.SiteTree.EditTitleNew;
					else ViewBag.Title = Resources.SiteTree.EditTitleExisting;

					ErrorMessage(Resources.SiteTree.MessageNotSaved);
				}
			}
			return View(m);
		}
Beispiel #3
0
		/// <summary>
		/// Gets the edit model for the comment with the given id.
		/// </summary>
		/// <param name="id">The comment id.</param>
		/// <returns></returns>
		public static SiteTreeEditModel GetById(Guid id) {
			using (var db = new DataContext()) {
				var site = db.SiteTrees.Where(s => s.Id == id).Single() ;
				var model = new SiteTreeEditModel(site.NamespaceId) {
					Id = site.Id,
					InternalId = site.InternalId,
					Name = site.Name,
					NamespaceId = site.NamespaceId,
					HostNames = site.HostNames,
					Description = site.Description,
					MetaTitle = site.MetaTitle,
					MetaDescription = site.MetaDescription,
					CanDelete = db.PageDrafts.Where(p => p.SiteTreeId == site.Id && (!p.ParentId.HasValue || p.ParentId.Value != site.Id)).Count() == 0,
					Template = db.PageTemplates.Include(pt => pt.RegionTemplates).Where(pt => pt.Id == site.Id && pt.IsSiteTemplate).SingleOrDefault()
				} ;
				if (model.Template == null) {
					model.Template = new PageTemplate() {
						Id = site.Id,
						Name = site.Id.ToString(),
						IsSiteTemplate = true
					} ;
				} else {
					model.Template.RegionTemplates = model.Template.RegionTemplates.OrderBy(r => r.Seqno).ToList() ;
				}
				model.Regions = model.Template.RegionTemplates ;
				return model ;
			}
		}