// GET: Arts/Delete/5 public ActionResult Delete(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Art art = db.Arts.Find(id); ArtsViewModel artViewModel = new ArtsViewModel(); if (art == null) { return HttpNotFound(); } else { artViewModel.Art_ID = art.Art_ID; artViewModel.User_ID = art.User_ID; artViewModel.Category = db.Categories.Where(x => x.CategoryId == art.Category_ID).FirstOrDefault(); artViewModel.Location = db.Locations.Where(x => x.LocationID == art.Location_ID).FirstOrDefault(); artViewModel.Location_ID = art.Location_ID; artViewModel.Category_ID = art.Category_ID; artViewModel.Title = art.Title; artViewModel.Subject = art.Subject; artViewModel.Price = art.Price; artViewModel.Medium = art.Medium; artViewModel.Statement = art.Statement; artViewModel.Size = art.Size; artViewModel.Created = art.Created; artViewModel.Modified = art.Modified; artViewModel.Cover_Pic_Path = art.Cover_Pic_Path == null ? Global.DefaultCoverPic : art.Cover_Pic_Path; artViewModel.Art_Images = db.Images.Where(x => x.Art_ID == art.Art_ID).Select(x => x.Path).ToList(); } return View(artViewModel); }
// GET: Arts/Edit/5 public ActionResult Edit(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } Art art = db.Arts.Find(id); ArtsViewModel model = new ArtsViewModel(); if (art == null) { return HttpNotFound(); } else { model.Art_ID = art.Art_ID; model.User_ID = art.User_ID; model.Location_ID = art.Location_ID; model.Category_ID = art.Category_ID; model.Title = art.Title; model.Subject = art.Subject; model.Price = art.Price; model.Medium = art.Medium; model.Statement = art.Statement; model.Size = art.Size; model.Created = art.Created; model.Modified = art.Modified; model.Cover_Pic_Path = art.Cover_Pic_Path; if (model.Cover_Pic_Path == null) model.Cover_Pic_Path = "~/Images/Default Images/CoverPic.png"; model.Images = art.Images; } return View(model); }