Esempio n. 1
0
        public ActionResult Edit([Bind(Include = "PirateID,FirstName,LastName,ResumeFilename,HasScurvy")] PirateDetail pirateDetail, HttpPostedFileBase resume)
        {
            if (ModelState.IsValid)
            {
                string resumeName = "";
                if (resume != null)
                {
                    resumeName = resume.FileName;

                    string   ext      = resumeName.Substring(resumeName.LastIndexOf('.'));
                    string[] goodExts = { ".doc", ".docx", ".pdf", ".rtf", ".txt" };

                    if (goodExts.Contains(ext.ToLower()))
                    {
                        resumeName = Guid.NewGuid() + ext;
                        resume.SaveAs(Server.MapPath("~/Content/Resumes/" + resumeName));
                    }
                    else
                    {
                        resumeName = "No Resume Uploaded";
                    }

                    pirateDetail.ResumeFilename = resumeName;
                }

                db.Entry(pirateDetail).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(pirateDetail));
        }
 public ActionResult Edit([Bind(Include = "AssignmentID,AssignmentName,AssignmentDescription")] Assignment assignment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(assignment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(assignment));
 }
 public ActionResult Edit([Bind(Include = "ApplicationStatusID,StatusName,StatusDescription")] ApplicationStatus applicationStatus)
 {
     if (ModelState.IsValid)
     {
         db.Entry(applicationStatus).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(applicationStatus));
 }
Esempio n. 4
0
 public ActionResult Edit([Bind(Include = "OpenAssignmentID,AssignmentID,ShipID")] OpenAssignment openAssignment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(openAssignment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AssignmentID = new SelectList(db.Assignments, "AssignmentID", "AssignmentName", openAssignment.AssignmentID);
     ViewBag.ShipID       = new SelectList(db.Ships, "ShipID", "ShipName", openAssignment.ShipID);
     return(View(openAssignment));
 }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "ApplicationID,OpenAssignmentID,PirateID,ApplicationDate,CaptainNotes,ApplicationStatus,ResumeFilename")] Application application)
 {
     if (ModelState.IsValid)
     {
         db.Entry(application).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ApplicationStatus = new SelectList(db.ApplicationStatus, "ApplicationStatusID", "StatusName", application.ApplicationStatus);
     //ViewBag.OpenAssignmentID = new SelectList(db.OpenAssignments, "OpenAssignmentID", "OpenAssignmentID", application.OpenAssignmentID);
     //ViewBag.PirateID = new SelectList(db.PirateDetails, "PirateID", "FirstName", application.PirateID);
     return(View(application));
 }
Esempio n. 6
0
        public ActionResult Edit([Bind(Include = "ShipID,ShipName,HomePort,CaptainID")] Ship ship)
        {
            var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext()));

            var pirates = db.PirateDetails.ToList();
            List <PirateDetail> captains = new List <PirateDetail>();

            foreach (var pirate in pirates)
            {
                if (userManager.IsInRole(pirate.PirateID, "Captain"))
                {
                    captains.Add(pirate);
                }
            }
            if (ModelState.IsValid)
            {
                db.Entry(ship).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CaptainID = new SelectList(captains, "PirateID", "FullName");
            return(View(ship));
        }