public ActionResult ResumeUpload() { AlumniDBModel db = new AlumniDBModel(); var image = Request.Files["resume"]; if (image == null) { ViewBag.UploadMessage = "Failed to upload image"; } else { Stream resumeStream = image.InputStream; ContactProfile profileId = (from contact in db.ContactProfiles where contact.PrimaryEmail == User.Identity.Name select contact).FirstOrDefault(); UserResume refreshModel = db.UserResumes.FirstOrDefault(r => r.ProfileID == profileId.ProfileId); byte[] resumeBytes; using (BinaryReader binaryData = new BinaryReader(resumeStream)) { resumeBytes = binaryData.ReadBytes((int)resumeStream.Length);//must convert long to int } refreshModel.ResumeImg = resumeBytes; db.Entry(refreshModel).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Edit", "Admin")); }
public ActionResult DeleteConfirmed(int id) { UserResume userResume = db.UserResumes.Find(id); db.UserResumes.Remove(userResume); db.SaveChanges(); return(RedirectToAction("Index")); }
public JsonResult Create(ResumeModel model) { UserResume candidate = new UserResume(); candidate.JobProfession = model.JobProfession; candidate.ExpierenceYear = model.ExperienceYear; candidate.UserId = _auth.User.UserId; candidate.PersonalSkill = model.PersonalSkill; _context.UserResumes.Add(candidate); _context.SaveChanges(); _auth.User.HasResume = true; if (model.Works != null) { for (var i = 0; i < model.Works.Count; i++) { Work experience = new Work { CompanyName = model.Works[i].CompanyName, StartWorkYear = model.Works[i].StartWork, EndWorkYear = model.Works[i].EndWork, ResumeId = candidate.ResumeId, Position = model.Works[i].Position, }; _context.Works.Add(experience); _context.SaveChanges(); } } if (model.Educations != null) { for (var i = 0; i < model.Educations.Count; i++) { Education education = new Education { SchoolName = model.Educations[i].SchoolName, StartEducationYear = model.Educations[i].StartSchool, EndEducationYear = model.Educations[i].EndSchool, ResumeId = candidate.ResumeId, Qualification = model.Educations[i].Qualification }; _context.Educations.Add(education); _context.SaveChanges(); } } return(Json(new { status = "OK", code = 200, message = "added Cv", data = model, redirectUrl = Url.Action("Index", "Home"), isRedirect = true })); }
//allows pdf's to be uploaded (images will not show for resume's based on application/pdf for the MIME type) public ActionResult GetResumeImg(int ResumeId) { UserResume resume = db.UserResumes.Single(r => r.UserResumeID == ResumeId); if (resume != null && resume.ResumeImg != null) { return(new FileContentResult(resume.ResumeImg, "application/pdf")); } return(null); }
public ActionResult Edit([Bind(Include = "UserResumeID,ProfileID,HtmlUpload")] UserResume userResume) { if (ModelState.IsValid) { db.Entry(userResume).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProfileID = new SelectList(db.ContactProfiles, "ProfileId", "FirstName", userResume.ProfileID); return(View(userResume)); }
// GET: UserResume_auto_/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserResume userResume = db.UserResumes.Find(id); if (userResume == null) { return(HttpNotFound()); } return(View(userResume)); }
// GET: UserResume_auto_/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } UserResume userResume = db.UserResumes.Find(id); if (userResume == null) { return(HttpNotFound()); } ViewBag.ProfileID = new SelectList(db.ContactProfiles, "ProfileId", "FirstName", userResume.ProfileID); return(View(userResume)); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.ActionParameters.Keys.Contains("id")) { if (filterContext.ActionParameters["id"].ToString() != null) { int id = Convert.ToInt32(filterContext.ActionParameters["id"].ToString()); string userid = filterContext.HttpContext.User.Identity.GetUserId().ToString(); using (var context = new ResumeCreatorEntities()) { UserResume userresume = context.UserResumes.SingleOrDefault(u => u.PersonalId == id && u.UserId == userid); if (userresume != null) { base.OnActionExecuting(filterContext); } else { filterContext.Result = new RedirectResult("~/Home/Index"); } } } } }
public async Task <ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { //await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string 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 <a href=\"" + callbackUrl + "\">here</a>"); await this.UserManager.AddToRoleAsync(user.Id, model.Name); AlumniDBModel db = new AlumniDBModel(); ContactProfile newContact = new ContactProfile(); newContact.FirstName = user.FirstName; newContact.LastName = user.LastName; newContact.PrimaryEmail = user.Email; db.ContactProfiles.Add(newContact); db.Entry(newContact).State = EntityState.Added; db.SaveChanges(); ContactProfile profileId = (from contact in db.ContactProfiles where contact.PrimaryEmail == user.Email select contact).FirstOrDefault(); //string connectionStringResume = ConfigurationManager.ConnectionStrings[2].ConnectionString; //using (SqlConnection connection = new SqlConnection(connectionStringResume)) //{ // connection.Open(); // UserResume newResume = new UserResume(); // newResume.ProfileID = profileId.ProfileId; // newResume.HtmlUpload = " "; // db.UserResumes.Add(newResume); // SqlCommand cmd = new SqlCommand("INSERT INTO UserResume(ProfileID,HtmlUpload) Values (@fName,@html)"); // cmd.CommandType = CommandType.Text; // cmd.Connection = connection; // cmd.Parameters.AddWithValue("@fName", profileId.ProfileId); // cmd.Parameters.AddWithValue("@html", ' '); // cmd.ExecuteNonQuery(); //} UserResume newResume = new UserResume(); newResume.ProfileID = profileId.ProfileId; newResume.HtmlUpload = " "; db.UserResumes.Add(newResume); db.SaveChanges(); //UserResume newResume = new UserResume(); //newResume.ContactProfile = profileId; //newResume.ProfileID = profileId.ProfileId; //newResume.HtmlUpload = " "; //db.UserResumes.Add(newResume); //db.SaveChanges(); ModelState.Clear(); ViewBag.Name = new SelectList(context.Roles.ToList(), "Name", "Name"); return(View()); } AddErrors(result); } ViewBag.Name = new SelectList(context.Roles.ToList(), "Name", "Name"); // If we got this far, something failed, redisplay form return(View()); }
public JsonResult Edit(ResumeModel model) { UserResume candidate = _context.UserResumes.Find(_auth.User.Resumes.ResumeId); candidate.JobProfession = model.JobProfession; candidate.ExpierenceYear = model.ExperienceYear; candidate.UserId = _auth.User.UserId; candidate.PersonalSkill = model.PersonalSkill; _context.SaveChanges(); var Works = _context.Works.Where(e => e.ResumeId == _auth.User.Resumes.ResumeId).ToList(); if (model.Works != null) { if (model.Works.Count == Works.Count) { for (var j = 0; j < Works.Count; j++) { Works[j].CompanyName = model.Works[j].CompanyName; Works[j].StartWorkYear = model.Works[j].StartWork; Works[j].EndWorkYear = model.Works[j].EndWork; Works[j].ResumeId = candidate.ResumeId; Works[j].Position = model.Works[j].Position; } } else if (model.Works.Count > Works.Count) { for (var j = 0; j < Works.Count; j++) { Works[j].CompanyName = model.Works[j].CompanyName; Works[j].StartWorkYear = model.Works[j].StartWork; Works[j].EndWorkYear = model.Works[j].EndWork; Works[j].Position = model.Works[j].Position; } for (var k = Works.Count; k < model.Works.Count; k++) { Work experience = new Work { CompanyName = model.Works[k].CompanyName, StartWorkYear = model.Works[k].StartWork, EndWorkYear = model.Works[k].EndWork, ResumeId = candidate.ResumeId, Position = model.Works[k].Position }; _context.Works.Add(experience); } } else if (Works.Count > model.Works.Count) { for (var j = 0; j < model.Works.Count; j++) { Works[j].CompanyName = model.Works[j].CompanyName; Works[j].StartWorkYear = model.Works[j].StartWork; Works[j].EndWorkYear = model.Works[j].EndWork; Works[j].ResumeId = candidate.ResumeId; Works[j].Position = model.Works[j].Position; } for (var t = model.Works.Count; t < Works.Count; t++) { _context.Works.Remove(Works[t]); } } } else if (model.Works == null) { for (var t = 0; t < Works.Count; t++) { _context.Works.Remove(Works[t]); } } //Educations of resume var educations = _context.Educations.Where(e => e.ResumeId == _auth.User.Resumes.ResumeId).ToList(); if (model.Educations != null) { if (model.Educations.Count == educations.Count) { for (var j = 0; j < educations.Count; j++) { educations[j].SchoolName = model.Educations[j].SchoolName; educations[j].StartEducationYear = model.Educations[j].StartSchool; educations[j].EndEducationYear = model.Educations[j].EndSchool; educations[j].ResumeId = candidate.ResumeId; educations[j].Qualification = model.Educations[j].Qualification; } } else if (model.Educations.Count > educations.Count) { for (var j = 0; j < educations.Count; j++) { educations[j].SchoolName = model.Educations[j].SchoolName; educations[j].StartEducationYear = model.Educations[j].StartSchool; educations[j].EndEducationYear = model.Educations[j].EndSchool; educations[j].Qualification = model.Educations[j].Qualification; } for (var k = educations.Count; k < model.Educations.Count; k++) { Education education = new Education { SchoolName = model.Educations[k].SchoolName, StartEducationYear = model.Educations[k].StartSchool, EndEducationYear = model.Educations[k].EndSchool, ResumeId = candidate.ResumeId, Qualification = model.Educations[k].Qualification, }; _context.Add(education); } } else if (educations.Count > model.Educations.Count) { for (var j = 0; j < model.Educations.Count; j++) { educations[j].SchoolName = model.Educations[j].SchoolName; educations[j].StartEducationYear = model.Educations[j].StartSchool; educations[j].EndEducationYear = model.Educations[j].EndSchool; educations[j].Qualification = model.Educations[j].Qualification; } for (var t = model.Educations.Count; t < educations.Count; t++) { _context.Educations.Remove(educations[t]); } } } else if (model.Educations == null) { for (var t = 0; t < educations.Count; t++) { _context.Educations.Remove(educations[t]); } } _context.SaveChanges(); return(Json(new { status = "OK", code = 200, message = "added Cv", data = model, redirectUrl = Url.Action("Index", "Home"), isRedirect = true })); }