public ActionResult Update(int? id, string title, string body, DateTime datetime, string tags) { if (!IsAdmin) { return RedirectToAction("Index"); } Post post = GetPost(id); post.Title = title; post.Body = body; post.DateTime = datetime; post.Tags.Clear(); tags = tags ?? string.Empty; string[] tagNames = tags.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string tagName in tagNames) { post.Tags.Add(GetTag(tagName)); } if (!id.HasValue) { model.AddToPosts(post); } model.SaveChanges(); return RedirectToAction("Details", new { id = post.ID }); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)