public ActionResult Create(FormCollection form) { var article = new Article { Name = Utils.Transliterator.Transliterate(form["Name"]), Date = Convert.ToDateTime(form["ArtDate"]), Text = HttpUtility.HtmlDecode(form["Text"]) }; TryUpdateModel(article, new[] {"Description", "Title", "Published" }); _context.AddToArticle(article); _context.SaveChanges(); return RedirectToAction("About", "Home", new { area = "" }); }
public BuildingModel(SiteContext context, string categoryId, string subCategoryId, int contentType, string articleId=null) : base(context, null) { _categoryId = categoryId; _subCategoryId = subCategoryId; _contentId = subCategoryId ?? categoryId; _buildings = context.Building.Include("Children").Include("BuildingItems").Where(b => b.ContentType == contentType).ToList(); if (categoryId != null) if (subCategoryId == null) ParentTitle = _buildings.Single(t => t.CategoryLevel == 0).Title; Building = _buildings.FirstOrDefault(t => t.Name == _contentId) ?? _buildings.First(t => t.CategoryLevel == 0); if (!HttpContext.Current.Request.IsAuthenticated) { if (Building.CategoryLevel == 0 && !Building.Active) { Building = _buildings.Where(t => t.Parent == null && t.CategoryLevel != 0).Where(t => t.SortOrder == _buildings.Min(c => (int?)c.SortOrder)).FirstOrDefault(); //Building = _buildings.FirstOrDefault(t => t.Parent == null && t.CategoryLevel != 0); if (Building != null) { ActiveCategoryNotFound = true; RedirectCategoryId = Building.Name; return; } } if (Building != null) { if (Building.CategoryLevel != 0 && !Building.Active && Building.Children.Any()) { ActiveCategoryNotFound = true; RedirectCategoryId = Building.Name; RedirectSubCategoryId = Building.Children.First().Name; return; } } } if (Building != null) { if (Building.Parent != null) { ParentTitle = Building.Parent.Title; } SeoDescription = Building.SeoDescription; SeoKeywords = Building.SeoKeywords; } GetMenu(); if (contentType == 1) { BuildingObjects = context.BuildingObj.ToList(); } if (articleId != null) Article = context.Article.First(a => a.Name == articleId); }
/// <summary> /// Create a new Article object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="title">Initial value of the Title property.</param> /// <param name="description">Initial value of the Description property.</param> /// <param name="text">Initial value of the Text property.</param> /// <param name="date">Initial value of the Date property.</param> /// <param name="published">Initial value of the Published property.</param> public static Article CreateArticle(global::System.Int32 id, global::System.String name, global::System.String title, global::System.String description, global::System.String text, global::System.DateTime date, global::System.Boolean published) { Article article = new Article(); article.Id = id; article.Name = name; article.Title = title; article.Description = description; article.Text = text; article.Date = date; article.Published = published; return article; }
/// <summary> /// Deprecated Method for adding a new object to the Article EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToArticle(Article article) { base.AddObject("Article", article); }