public async Task <ActionResult> DeleteConfirmed(int id) { SquareSet squareSet = await _db.SquareSets.FindAsync(id); _db.SquareSets.Remove(squareSet); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); }
// GET: SquareSets/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SquareSet squareSet = await _db.SquareSets.FindAsync(id); if (squareSet == null) { return(HttpNotFound()); } return(View(squareSet)); }
public async Task <ActionResult> Create(SquareSetViewModel squareSetViewModel) { var squareSet = new SquareSet { Name = squareSetViewModel.Name, UserId = User.Identity.GetUserId() }; if (ModelState.IsValid) { _db.SquareSets.Add(squareSet); UploadImages(squareSetViewModel); await _db.SaveChangesAsync(); return(RedirectToAction("Details", new { id = squareSet.Id })); } return(View(squareSet)); }
public async Task <ActionResult> Edit([Bind(Exclude = "CurrentPieces")] EditSquareSetViewModel squareSetViewModel) { if (squareSetViewModel.Id == 0) { return(View(squareSetViewModel)); } SquareSet squareSet = _db.SquareSets.First(o => o.Id == squareSetViewModel.Id); squareSetViewModel.CurrentPieces = squareSet.Pieces; if (ModelState.IsValid) { squareSet.Name = squareSetViewModel.Name; UploadImages(squareSetViewModel); await _db.SaveChangesAsync(); return(RedirectToAction("Details", new { id = squareSet.Id })); } return(View(squareSetViewModel)); }
// GET: SquareSets/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SquareSet squareSet = await _db.SquareSets.FindAsync(id); if (squareSet == null) { return(HttpNotFound()); } var squareSetViewModel = new EditSquareSetViewModel { Id = squareSet.Id, Name = squareSet.Name, CurrentPieces = squareSet.Pieces }; return(View(squareSetViewModel)); }