public ActionResult Create([Bind(Include = "AssignmentID,AssignmentName,AssignmentDescription")] Assignment assignment)
        {
            if (ModelState.IsValid)
            {
                db.Assignments.Add(assignment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(assignment));
        }
        public ActionResult Create([Bind(Include = "ApplicationStatusID,StatusName,StatusDescription")] ApplicationStatus applicationStatus)
        {
            if (ModelState.IsValid)
            {
                db.ApplicationStatus.Add(applicationStatus);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(applicationStatus));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Register(RegisterViewModel model, HttpPostedFileBase resume)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    #region Custom User Details
                    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 = "";
                        }
                    }

                    PirateDetail newPirateDetails = new PirateDetail();
                    newPirateDetails.PirateID       = user.Id;
                    newPirateDetails.FirstName      = model.FirstName;
                    newPirateDetails.LastName       = model.LastName;
                    newPirateDetails.ResumeFilename = resumeName;
                    newPirateDetails.HasScurvy      = model.HasScurvy;



                    PirateJobBoardEntities db = new PirateJobBoardEntities();
                    db.PirateDetails.Add(newPirateDetails);
                    db.SaveChanges();
                    #endregion

                    UserManager.AddToRole(user.Id, "Crewmate");
                    var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    //await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
                    //ViewBag.Link = callbackUrl;
                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "OpenAssignmentID,AssignmentID,ShipID")] OpenAssignment openAssignment)
        {
            if (ModelState.IsValid)
            {
                db.OpenAssignments.Add(openAssignment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            string userID = User.Identity.GetUserId();

            if (User.IsInRole("Captain"))
            {
                var captainsShip = db.Ships.Where(x => x.CaptainID == userID).ToList();
                ViewBag.AssignmentID = new SelectList(db.Assignments, "AssignmentID", "AssignmentName");
                ViewBag.ShipID       = new SelectList(captainsShip, "ShipID", "ShipName");
                return(View(openAssignment));
            }

            ViewBag.AssignmentID = new SelectList(db.Assignments, "AssignmentID", "AssignmentName", openAssignment.AssignmentID);
            ViewBag.ShipID       = new SelectList(db.Ships, "ShipID", "ShipName", openAssignment.ShipID);
            return(View(openAssignment));
        }
Ejemplo n.º 6
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));
 }
Ejemplo n.º 7
0
        public ActionResult Create([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.Ships.Add(ship);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CaptainID = new SelectList(captains, "PirateID", "FullName");
            return(View(ship));
        }