public ActionResult Edit(Link link) { if (ModelState.IsValid) { db.Entry(link).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(link); }
public ActionResult Create(Link link) { if (ModelState.IsValid) { db.Links.Add(link); db.SaveChanges(); return RedirectToAction("Index"); } return View(link); }
public JsonResult SaveLink(LinkViewModel model) { var link = new Link { Title = model.Title, Description = model.Description, Url = model.Url, Tags = model.Tags.Split(' ').Select(x => new Tag{ Name = x}).ToList() }; db.Links.Add(link); db.SaveChanges(); return Json(new {Success = true}); }