public ActionResult Edit(int id, string title, string goalAmount, string collectedAmount, string info, HttpPostedFileBase logo) { string fileName = logo != null?System.IO.Path.GetFileName(logo.FileName) : null; if (!String.IsNullOrEmpty(fileName)) { logo.SaveAs(Server.MapPath("~/images/" + fileName)); } Fund fund = db.Funds.Find(id); fund.Title = title; fund.GoalAmount = Convert.ToInt32(goalAmount); fund.CollectedAmount = String.IsNullOrEmpty(collectedAmount) ? 0 : Convert.ToInt32(collectedAmount); fund.Info = info; if (!String.IsNullOrEmpty(fileName)) { logo.SaveAs(Server.MapPath("~/images/" + fileName)); fund.LogoName = fileName; } db.Entry(fund).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "FundId,Title,GoalAmount,CollectedAmount,Info,LogoName")] Fund fund) { if (ModelState.IsValid) { db.Entry(fund).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(fund)); }
public ActionResult Edit([Bind(Include = "Id,FundId,Name,Amount,Message")] Philanthropist philanthropist) { if (ModelState.IsValid) { db.Entry(philanthropist).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FundId = new SelectList(db.Funds, "FundId", "Title", philanthropist.FundId); return(View(philanthropist)); }