// GET: GeneralCoins/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GeneralCoin generalCoin = db.GeneralCoins.Find(id); if (generalCoin == null) { return(HttpNotFound()); } var coins = db.CoinsCollections.Where(m => m.GeneralCoinId == generalCoin.GeneralCoinId); if (coins.Count() <= 0) { db.GeneralCoins.Remove(generalCoin); db.SaveChanges(); } else { foreach (var item in coins) { CoinsCollection moneda = item; db.CoinsCollections.Remove(moneda); } db.GeneralCoins.Remove(generalCoin); db.SaveChanges(); } return(RedirectToAction("Index")); }
// GET: CoinsCollections/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CoinsCollection coinsCollection = db.CoinsCollections.Find(id); if (coinsCollection == null) { return(HttpNotFound()); } ViewBag.EdgeId = new SelectList(db.EdgeInscriptions, "EdgeId", "Inscription", coinsCollection.EdgeId); ViewBag.GeneralCoinId = new SelectList(db.GeneralCoins, "GeneralCoinId", "Value", coinsCollection.GeneralCoinId); ViewBag.PortretDesignerId = new SelectList(db.PortretDesigners, "DesignerId", "Name", coinsCollection.PortretDesignerId); ViewBag.ReverseDesignerId = new SelectList(db.ReverseDesigners, "DesignerId", "Name", coinsCollection.ReverseDesignerId); SelectList listYears = new SelectList(years, coinsCollection.Year); ViewBag.listOfYears = listYears; return(View(coinsCollection)); }
public ActionResult Create([Bind(Include = "CoinId,GeneralCoinId,PortretDesignerId,ReverseDesignerId,EdgeId,Year,Mintage,EstimatedValues")] CoinsCollection coinsCollection, HttpPostedFileBase Image) { coinsCollection.Image = ""; if ((Image.ContentLength) > 0 && (Image != null)) { string imageName = Path.GetFileName(Image.FileName); string path = Path.Combine(Server.MapPath("~/Content/Coins"), imageName); Image.SaveAs(path); coinsCollection.Image = imageName; } if (ModelState.IsValid) { db.CoinsCollections.Add(coinsCollection); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EdgeId = new SelectList(db.EdgeInscriptions, "EdgeId", "Inscription", coinsCollection.EdgeId); ViewBag.GeneralCoinId = new SelectList(db.GeneralCoins, "GeneralCoinId", "Value", coinsCollection.GeneralCoinId); ViewBag.PortretDesignerId = new SelectList(db.PortretDesigners, "DesignerId", "Name", coinsCollection.PortretDesignerId); ViewBag.ReverseDesignerId = new SelectList(db.ReverseDesigners, "DesignerId", "Name", coinsCollection.ReverseDesignerId); return(View(coinsCollection)); }
// GET: CoinsCollections/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CoinsCollection coinsCollection = db.CoinsCollections.Find(id); if (coinsCollection == null) { return(HttpNotFound()); } return(View(coinsCollection)); }
// GET: CoinsCollections/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CoinsCollection coinsCollection = db.CoinsCollections.Find(id); if (coinsCollection == null) { return(HttpNotFound()); } db.CoinsCollections.Remove(coinsCollection); db.SaveChanges(); return(RedirectToAction("Index", new { href = Request.UrlReferrer })); }