public ActionResult DeleteConfirmed(int id) { ConsultantExpertise consultantExpertise = db.ConsultantExpertises.Find(id); db.ConsultantExpertises.Remove(consultantExpertise); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult DeleteExpertise(int id) { OrcaContext db = new OrcaContext(); ConsultantExpertise expertise = db.ConsultantExpertises.Find(id); db.ConsultantExpertises.Remove(expertise); db.SaveChanges(); return(RedirectToAction("UserProfile")); }
public ActionResult Edit([Bind(Include = "ConsultantExpertiseID,OrcaUserID,FieldOfExpertise")] ConsultantExpertise consultantExpertise) { if (ModelState.IsValid) { db.Entry(consultantExpertise).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrcaUserID = new SelectList(db.ExpertConsultants, "OrcaUserID", "TitleDegree", consultantExpertise.OrcaUserID); ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", consultantExpertise.OrcaUserID); return(View(consultantExpertise)); }
// GET: zzzTESTinCASEConsultantExpertises/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ConsultantExpertise consultantExpertise = db.ConsultantExpertises.Find(id); if (consultantExpertise == null) { return(HttpNotFound()); } return(View(consultantExpertise)); }
// GET: zzzTESTinCASEConsultantExpertises/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ConsultantExpertise consultantExpertise = db.ConsultantExpertises.Find(id); if (consultantExpertise == null) { return(HttpNotFound()); } ViewBag.OrcaUserID = new SelectList(db.ExpertConsultants, "OrcaUserID", "TitleDegree", consultantExpertise.OrcaUserID); ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", consultantExpertise.OrcaUserID); return(View(consultantExpertise)); }
protected override void Seed(OrcaContext context) { //base.Seed(context); // add a regular user for testing initialization OrcaUser generalUser = new OrcaUser(); generalUser.OrcaPassword = new OrcaPassword(); generalUser.OrcaUserName = "******"; generalUser.FirstName = "Test"; generalUser.LastName = "User"; generalUser.OrcaPassword.Password = "******"; generalUser.Email = "*****@*****.**"; generalUser.PhoneNumber = "3045432101"; generalUser.IsAccountDeactivated = false; generalUser.UserType = OrcaUserType.Consultee; context.OrcaUsers.Add(generalUser); context.SaveChanges(); // add a regular expert consultant for testing initialization OrcaUser expertUser = new OrcaUser(); expertUser.OrcaPassword = new OrcaPassword(); expertUser.OrcaUserName = "******"; expertUser.FirstName = "Test"; expertUser.LastName = "Expert"; expertUser.OrcaPassword.Password = "******"; expertUser.Email = "*****@*****.**"; expertUser.PhoneNumber = "1234567890"; expertUser.IsAccountDeactivated = false; expertUser.UserType = OrcaUserType.Consultant; context.OrcaUsers.Add(expertUser); context.SaveChanges(); ExpertConsultant expertUserConsultant = new ExpertConsultant(); expertUserConsultant.OrcaUserID = expertUser.OrcaUserID; expertUserConsultant.ExpertStatus = ExpertStatus.Approved; expertUserConsultant.IsActive = true; context.ExpertConsultants.Add(expertUserConsultant); context.SaveChanges(); ConsultantExpertise consultantExpertise = new ConsultantExpertise(); consultantExpertise.OrcaUserID = expertUserConsultant.OrcaUserID; consultantExpertise.FieldOfExpertise = "Computer Science"; context.ConsultantExpertises.Add(consultantExpertise); context.SaveChanges(); // add an admin expert consultant for testing initialization expertUser = new OrcaUser(); expertUser.OrcaPassword = new OrcaPassword(); expertUser.OrcaUserName = "******"; expertUser.FirstName = "Admin"; expertUser.LastName = "Expert"; expertUser.OrcaPassword.Password = "******"; expertUser.Email = "*****@*****.**"; expertUser.PhoneNumber = "1234567890"; expertUser.IsAccountDeactivated = false; expertUser.UserType = OrcaUserType.ConsultantAdmin; context.OrcaUsers.Add(expertUser); context.SaveChanges(); expertUserConsultant = new ExpertConsultant(); expertUserConsultant.OrcaUserID = expertUser.OrcaUserID; expertUserConsultant.ExpertStatus = ExpertStatus.Approved; expertUserConsultant.IsActive = true; context.ExpertConsultants.Add(expertUserConsultant); context.SaveChanges(); consultantExpertise = new ConsultantExpertise(); consultantExpertise.OrcaUserID = expertUserConsultant.OrcaUserID; consultantExpertise.FieldOfExpertise = "Software Engineering"; context.ConsultantExpertises.Add(consultantExpertise); context.SaveChanges(); }
public static UserProfile ChangeUserProfileInfo(UserProfile profileChanges) { OrcaContext db = new OrcaContext(); OrcaUser orcaUser = db.OrcaUsers.Find(profileChanges.OrcaUserID); if (orcaUser != null) { // update any allowed changes that may have been made orcaUser.FirstName = profileChanges.FirstName; orcaUser.LastName = profileChanges.LastName; orcaUser.Email = profileChanges.Email; orcaUser.PhoneNumber = profileChanges.PhoneNumber; // update the database db.Entry(orcaUser).State = EntityState.Modified; db.SaveChanges(); if (orcaUser.UserType == OrcaUserType.Consultant || orcaUser.UserType == OrcaUserType.ConsultantAdmin) { ExpertConsultant expertConsultant = db.ExpertConsultants.Find(orcaUser.OrcaUserID); if (expertConsultant != null) { // update any allowed changes that may have been made expertConsultant.TitleDegree = profileChanges.TitleDegree; expertConsultant.KeyWordList = profileChanges.KeyWordList; // IsActive is done this way to allow a drop down list for the profile view if (profileChanges.IsActive == ActiveStatus.Yes) { expertConsultant.IsActive = true; } else { expertConsultant.IsActive = false; } // update the database db.Entry(expertConsultant).State = EntityState.Modified; db.SaveChanges(); // this isn't pretty, but i was doing it this way while trying to figure out where a problem was occuring. since its done, i'll leave it alone for now, after all, it is a prototype // add the new field of expertise if it is entered if (!(String.IsNullOrEmpty(profileChanges.FieldToAdd) || String.IsNullOrWhiteSpace(profileChanges.FieldToAdd)))// make sure something was entered in FieldToAdd { // get a list of current expertises List <ConsultantExpertise> userExpertises = (from expertise in db.ConsultantExpertises where expertise.OrcaUserID == profileChanges.OrcaUserID select expertise).ToList(); if (userExpertises.Count() <= 0 || userExpertises.All(ex => ex.FieldOfExpertise != profileChanges.FieldToAdd))// make sure that we aren't duplicating any expertises { ConsultantExpertise newField = new ConsultantExpertise(); newField.OrcaUserID = profileChanges.OrcaUserID; newField.FieldOfExpertise = profileChanges.FieldToAdd; db.ConsultantExpertises.Add(newField); db.SaveChanges(); } } } } } return(profileChanges); }