public ActionResult Edit([Bind(Include = "PositionID,Title,JobDescription")] Position position) { if (ModelState.IsValid) { db.Entry(position).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(position)); }
public ActionResult Edit([Bind(Include = "LocationID,StoreNumber,City,State,ManagerID")] Location location) { if (ModelState.IsValid) { db.Entry(location).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(location)); }
public ActionResult Edit([Bind(Include = "UserID,FirstName,LastName,ResumeFileName")] UserDetail userDetail, HttpPostedFileBase fupResume) { if (ModelState.IsValid) { #region FileUpload FOR EDIT if (fupResume != null) { //Get file and assign to variable string resumeName = fupResume.FileName; //declare and assign ext value string ext = resumeName.Substring(resumeName.LastIndexOf('.'));//get the extension including '.' //declare list of valid extensions string[] goodExts = { ".doc", ".docx", ".pdf", ".txt" }; //check the ext variable in lowercase vs valid list if (goodExts.Contains(ext.ToLower()) && (fupResume.ContentLength <= 4194304)) { //if it is in the list , rename it using a GUID (Unique is vital to avoid overwrite) resumeName = Guid.NewGuid() + ext; //save to the webserver at correct location fupResume.SaveAs(Server.MapPath("~/Content/resumes/" + resumeName)); //Housekeeping for edit: delete old file on record if not the default if (resumeName != null) { System.IO.File.Delete(Server.MapPath("~/Content/images/" + resumeName)); } //ONLY if file upload ok, change the new db record's file field to reflect userDetail.ResumeFileName = resumeName; } else { userDetail.ResumeFileName = "No resume.pdf"; throw new ApplicationException("Incorrect file type (use PNG, JPG or GIF), or file should not exceeds 4MB)"); } //end if tree for good extesion and good file size } //end if fup exists #endregion db.Entry(userDetail).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserID = new SelectList(db.AspNetUsers, "Id", "Email", userDetail.UserID); return(View(userDetail)); }
public ActionResult Edit([Bind(Include = "OpenPositionID,PositionID,LocationID")] OpenPosition openPosition) { if (ModelState.IsValid) { db.Entry(openPosition).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.LocationID = new SelectList(db.Locations, "LocationID", "StoreNumber", openPosition.LocationID); ViewBag.PositionID = new SelectList(db.Positions, "PositionID", "Title", openPosition.PositionID); return(View(openPosition)); }
public ActionResult Edit([Bind(Include = "ApplicationID,OpenPositionID,UserID,ApplicationDate,ManagerNotes,ApplicationStatusID,ResumeFileName")] Application application) { if (ModelState.IsValid) { db.Entry(application).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ApplicationStatusID = new SelectList(db.ApplicationStatus, "ApplicationStatusID", "ApplicationStatus", application.ApplicationStatusID); ViewBag.OpenPositionID = new SelectList(db.OpenPositions, "OpenPositionID", "OpenPositionID", application.OpenPositionID); ViewBag.UserID = new SelectList(db.UserDetails, "UserID", "FirstName", application.UserID); return(View(application)); }