public ActionResult Edit([Bind(Include = "OwnerAssetId,ChildName,OwnerId,ChildPhoto,SpecialNotes,IsActive,DateAdded,ChildDOB,SkillLevel")] OwnerAsset ownerAsset, HttpPostedFileBase childImage) { if (ModelState.IsValid) { #region FileUpload if (childImage != null) { string imageName = childImage.FileName; string ext = imageName.Substring(imageName.LastIndexOf('.')); string[] goodExts = new string[] { ".jpeg", ".jpg", ".png", ".gif" }; if (goodExts.Contains(ext.ToLower())) { imageName = Guid.NewGuid() + ext; childImage.SaveAs(Server.MapPath("~/Content/images/" + imageName)); string currentFile = Request.Params["ChildPhoto"]; if (currentFile != "noImage.png" && currentFile != null) { System.IO.File.Delete(Server.MapPath("~/Content/images/" + currentFile)); } } ownerAsset.ChildPhoto = imageName; } #endregion db.Entry(ownerAsset).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OwnerId = new SelectList(db.UserDetails, "UserId", "FirstName", ownerAsset.OwnerId); return(View(ownerAsset)); }
public ActionResult Edit([Bind(Include = "LocationId,LocationName,InstructorName,Address,City,State,Zip,ReservationLimit")] Location location) { if (ModelState.IsValid) { db.Entry(location).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(location)); }
public ActionResult Edit([Bind(Include = "ReservationId,OwnerAssetId,LocationId,ReservationDate")] Reservation reservation) { if (ModelState.IsValid) { db.Entry(reservation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.LocationId = new SelectList(db.Locations, "LocationId", "LocationName", reservation.LocationId); ViewBag.OwnerAssetId = new SelectList(db.OwnerAssets, "OwnerAssetId", "ChildName", reservation.OwnerAssetId); return(View(reservation)); }