public ActionResult Create(ExpertCreateViewModel expertVM) { if (ModelState.IsValid) { var localExperts1 = new LocalExperts1() { BU_FEIN = expertVM.BU_FEIN, Email = expertVM.Email, Business_Name = expertVM.Business_Name, Location_Zip = expertVM.Location_Zip, Name = expertVM.Name, Name_JobType = expertVM.Name_JobType, Phone_Number = expertVM.Phone_Number, JobTypes1 = new List <JobTypes1>() }; foreach (var JobTypeId in expertVM.JobTypes1) { localExperts1.JobTypes1.Add(db.JobTypes1.Find(JobTypeId)); } db.LocalExperts1.Add(localExperts1); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.TotalJobTypes = new MultiSelectList(db.JobTypes1.ToList(), "JobType_ID", "Name_JobType"); return(View(expertVM)); }
public ActionResult DeleteConfirmed(int id) { LocalExperts1 localExperts1 = db.LocalExperts1.Find(id); db.LocalExperts1.Remove(localExperts1); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "LocalExpert_ID,LocalExpert_UserID,Name,Email,Business_Name,Name_JobType,BU_FEIN,Location_Zip,Phone_Number")] LocalExperts1 localExperts1) { if (ModelState.IsValid) { db.Entry(localExperts1).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(localExperts1)); }
// GET: GeneralSearchExxperts/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LocalExperts1 localExperts1 = db.LocalExperts1.Find(id); if (localExperts1 == null) { return(HttpNotFound()); } return(View(localExperts1)); }
public async Task <ActionResult> RegisterExpert(RegisterExpertViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { var localExpert = new LocalExperts1() { BU_FEIN = model.BU_FEIN, Business_Name = model.BusinessName, Email = model.Email, LocalExpert_UserID = user.Id, Location_Zip = model.Location_Zip, Name = model.Name, Phone_Number = model.Phone_Number, Name_JobType = model.Name_JobType }; UserManager.AddToRole(user.Id, "LocalExpert"); db.LocalExperts1.Add(localExpert); db.SaveChanges(); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://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>"); //General Email Sender.... var subject = "welcome to GotAGuy"; var body = $"Hi! Thank you for signing up. We Couldn't Be Happier For You To Be With Us!"; MessageSender.SendEmail(model.Email, subject, body); return(RedirectToAction("Login", "Account")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }