public ActionResult Create(Zine zine) { // var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; // var currentUser = await _userManager.FindByIdAsync(userId); // organization.Owner = currentUser; // zine.Organization = _db.Organizations.FirstOrDefault(o => o.OrganizationId == zine.OrganizationId); _db.Zines.Add(zine); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult AddZine(int id) { var thisPost = _db.Posts.FirstOrDefault(posts => posts.PostId == id); List <Zine> selectedZines = _db.Zines.OrderBy(x => x.Name).ToList(); // Alphabetize ALL zines var postZines = _db.PostZine.Where(x => x.PostId == id).ToList(); // list of PostZines that match this post foreach (PostZine join in postZines) { Zine thisZine = _db.Zines.Find(join.ZineId); selectedZines.Remove(thisZine); } ViewBag.ZineId = new SelectList(selectedZines, "ZineId", "Name"); // ViewBag.ZineId = new SelectList(_db.Zines, "ZineId", "Name"); return(View(thisPost)); }
public ActionResult Edit(Zine zine) { _db.Entry(zine).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Details", "Zines", new { id = zine.ZineId })); }