public ActionResult skillEnquiry(profileViewModel model, string usID) { int uID = Convert.ToInt16(usID); tbClient client = db.tbClients.Where(c => c.userID.Equals(uID)).Single(); model.tbSkill.devID = client.tbDevelopers.FirstOrDefault().devID; db.tbSkills.Add(model.tbSkill); db.SaveChanges(); int skID = model.tbSkill.skillID; var action = from dev in db.tbClients where dev.userID == uID select dev; string actionUpdated = "skillEnquiry"; foreach (tbClient d in action) { d.actionCont = "quizVerify"; actionUpdated = d.actionCont; } db.SaveChanges(); TempData["skill"] = skID; return(RedirectToAction(actionUpdated, "Developer", new { id = skID })); }
public ActionResult viewProfile(string id) { int ID = Convert.ToInt16(id); profileViewModel model = new profileViewModel(); tbClient client = db.tbClients.Where(u => u.userID.Equals(ID)).FirstOrDefault(); model.tbDeveloper = client.tbDevelopers.FirstOrDefault(); model.tbEducations = client.tbEducations.ToList(); model.tbSkills = client.tbDevelopers.FirstOrDefault().tbSkills.ToList(); model.tbUser = client.tbUser; return(View(model)); }
public ActionResult profileDev() { var id = Convert.ToInt32(Session["devID"]); tbUserCredential user = db.tbUserCredentials.Where(u => u.userID.Equals(id)).FirstOrDefault(); tbClient client = db.tbClients.Where(u => u.userID.Equals(user.userID)).FirstOrDefault(); profileViewModel model = new profileViewModel(); model.tbDeveloper = client.tbDevelopers.FirstOrDefault(); model.tbSkills = client.tbDevelopers.FirstOrDefault().tbSkills.ToList(); model.tbUser = client.tbUser; return(View(model)); }
public ActionResult Home() { string username = Session["RA"].ToString(); RAModel model = new RAModel(); tbUserCredential uc = db.tbUserCredentials.Where(u => u.username.Equals(username)).FirstOrDefault(); tbClient client = db.tbClients.Where(c => c.userID.Equals(uc.userID)).FirstOrDefault(); model.tbReqEngineer = client.tbRequirementEngineers.Where(c => c.clientID.Equals(client.clientID)).FirstOrDefault(); model.proposals = model.tbReqEngineer.tbProjProposals.ToList(); model.awardedProjects = db.tbAwardedProjs.Where(aw => aw.raID == model.tbReqEngineer.raID).ToList(); model.workrooms = new List <tbProjWorkroom>(); foreach (var proj in model.awardedProjects) { tbProjWorkroom wr = db.tbProjWorkrooms.Where(w => w.projID.Equals(proj.projID)).First(); model.workrooms.Add(wr); } return(View(model)); }
public ActionResult quiz(string id) { int sklID = Convert.ToInt16(Session["sklID"].ToString()); quizViewModel model = new quizViewModel(); string username = Session["dev"].ToString(); tbUserCredential userCredential = db.tbUserCredentials.Where(uc => uc.username.Equals(username)).Single(); int Uid = userCredential.tbUser.userID; tbClient client = db.tbClients.Where(uc => uc.userID.Equals(Uid)).Single(); int devID = client.tbDevelopers.FirstOrDefault().devID; tbSkill skl = db.tbSkills.Where(uc => uc.devID.Equals(devID) && uc.skillID.Equals(sklID)).Single(); int i = Convert.ToInt16(id); List <tbQuestion> questions = db.tbQuestions.Where(q => q.skill.Equals(skl.name)).ToList(); if (i < questions.Count) { ViewBag.count = questions.Count; int Qid = questions[i].qID; List <tbAnswer> answers = db.tbAnswers.Where(a => a.qID == Qid).ToList(); model.tbSkill = skl; model.tbQuestion = questions; model.tbAnswer = answers; model.tbDeveloper = client.tbDevelopers.FirstOrDefault(); model.i = i; model.score = 0; } else { //quiz completed } return(View(model)); }
public ActionResult Register(userViewModel model) { if (ModelState.IsValid) { // Attempt to register the user try { WebSecurity.CreateUserAndAccount(model.RegisterModel.UserName, model.RegisterModel.Password); WebSecurity.Login(model.RegisterModel.UserName, model.RegisterModel.Password); //UsersContext Udb = new UsersContext(); //model.UserProfile.UserName = model.RegisterModel.UserName; //Udb.UserProfiles.Add(model.UserProfile); //Udb.SaveChanges(); model.tbUser.accountType = model.RegisterModel.AccountType; db.tbUsers.Add(model.tbUser); db.SaveChanges(); //var query = from a in db.tbUsers where a.firstName.Contains(model.tbUser.firstName) select a.userID; var cUserID = model.tbUser.userID; Session["usID"] = cUserID; string action = ""; string controller = ""; if (model.RegisterModel.AccountType.Equals("PM")) { tbPM PM = new tbPM(); PM.userID = cUserID; PM.totalSpending = "0"; PM.awardedProj = "0"; db.tbPMs.Add(PM); db.SaveChanges(); action = "Home"; controller = "PM"; Session["PM"] = model.RegisterModel.UserName; Session["pmID"] = cUserID; Session["PMname"] = model.tbUser.firstName + " " + model.tbUser.lastName; } else { tbClient client = new tbClient(); client.userID = cUserID; client.totalEarning = "0"; client.awardedProjects = "0"; client.tagLine = ""; client.overview = ""; client.isProfileComplete = "No"; client.actionCont = "skillEnquiry"; client.completedTasks = 0; db.tbClients.Add(client); db.SaveChanges(); if (model.RegisterModel.AccountType.Equals("Developer")) { tbDeveloper dev = new tbDeveloper(); int id = db.tbClients.Where(c => c.userID.Equals(cUserID)).FirstOrDefault().clientID; dev.clientID = id; dev.affiliation = ""; db.tbDevelopers.Add(dev); action = "skillEnquiry"; controller = "Developer"; Session["dev"] = model.RegisterModel.UserName; Session["devID"] = cUserID; Session["devname"] = model.tbUser.firstName + " " + model.tbUser.lastName; } else if (model.RegisterModel.AccountType.Equals("QA")) { tbQualityAssurance QA = new tbQualityAssurance(); int id = Convert.ToInt16(from a in db.tbClients where a.clientID.Equals(cUserID) select a.clientID); QA.clientID = id; db.tbQualityAssurances.Add(QA); action = "Home"; controller = "QualityAssurance"; } else if (model.RegisterModel.AccountType.Equals("RA")) { tbRequirementEngineer QA = new tbRequirementEngineer(); int id = db.tbClients.Where(c => c.userID.Equals(cUserID)).FirstOrDefault().clientID; QA.clientID = id; db.tbRequirementEngineers.Add(QA); action = "Home"; controller = "RequirementEngineer"; Session["RA"] = model.RegisterModel.UserName; Session["raID"] = cUserID; Session["RAname"] = model.tbUser.firstName + " " + model.tbUser.lastName; } } tbUserCredential uc = new tbUserCredential(); uc.userID = cUserID; uc.username = model.RegisterModel.UserName; uc.password = model.RegisterModel.Password; uc.email = model.RegisterModel.Email; uc.secretQ = "None"; uc.secretA = "None"; db.tbUserCredentials.Add(uc); db.SaveChanges(); return(RedirectToAction(action, controller)); } catch (MembershipCreateUserException e) { ModelState.AddModelError("", ErrorCodeToString(e.StatusCode)); } } // If we got this far, something failed, redisplay form return(View(model)); }