public ActionResult Edit([Bind(Include = "ID,clientId,CategoryID,Title,Content")] Recipe recipe) { if (recipe.Content == null || recipe.Title == null) { return(RedirectToAction("Index", "Home")); } if (!AuthorizationMiddleware.Authorized(Session)) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { recipe.CreationDate = DateTime.Now; _db.Entry(recipe).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClientID = new SelectList(_db.Clients, "ID", "ClientName", recipe.ClientId); ViewBag.CategoryID = new SelectList(_db.Categories, "ID", "Name", recipe.CategoryId); return(View(recipe)); }
public ActionResult Edit([Bind(Include = "ID,Name")] Category category) { if (!AuthorizationMiddleware.AdminAuthorized(Session)) { return(RedirectToAction("Index", "Home")); } if (!ModelState.IsValid) { return(View(category)); } _db.Entry(category).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,Gender,ClientName,FirstName,LastName,Password,isAdmin")] Client client) { if (!AuthorizationMiddleware.AdminAuthorized(Session)) { return(RedirectToAction("Index", "Home")); } if (!ModelState.IsValid) { return(View(client)); } _db.Entry(client).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,RecipeID,ClientId,Content,Score")] Comment comment) { if (!AuthorizationMiddleware.Authorized(Session)) { return(RedirectToAction("Index", "Home")); } if (ModelState.IsValid) { comment.CreationDate = DateTime.Now; _db.Entry(comment).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index", "Recipes")); } ViewBag.ClientID = new SelectList(_db.Clients, "ID", "ClientName", comment.ClientId); ViewBag.RecipeID = new SelectList(_db.Recipes, "ID", "Content", comment.RecipeId); return(View(comment)); }