public ActionResult Create([Bind(Include = "UserID,UserName,UserPassword")] UserProfile userProfile) { if (ModelState.IsValid) { db.UserProfiles.Add(userProfile); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userProfile)); }
public ActionResult Create([Bind(Include = "ProjectSpotlightID,ProfileID,ProjectName,Technologies,DevelopmentTime,ProjectDescription,RepoLink,Image_1,Image_2")] ProjectSpotlight projectSpotlight) { if (ModelState.IsValid) { db.ProjectSpotlights.Add(projectSpotlight); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProfileID = new SelectList(db.ContactProfiles, "ProfileId", "FirstName", projectSpotlight.ProfileID); return(View(projectSpotlight)); }
public ActionResult Create([Bind(Include = "UserResumeID,ProfileID,HtmlUpload")] UserResume userResume) { if (ModelState.IsValid) { db.UserResumes.Add(userResume); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProfileID = new SelectList(db.ContactProfiles, "ProfileId", "FirstName", userResume.ProfileID); return(View(userResume)); }
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 SaveProfile(AdminViewModel model) { if (ModelState.IsValid) { db.Entry(model.ContactProfile).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Admin")); } else { return(View(model)); } }
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()); }