Exemple #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));
        }
Exemple #2
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));
        }
Exemple #3
0
        // GET: PirateDetails/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PirateDetail pirateDetail = db.PirateDetails.Find(id);

            if (pirateDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(pirateDetail));
        }