Пример #1
0
        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));
        }
Пример #2
0
        public ActionResult Home()
        {
            var uName              = Session["dev"].ToString();
            var dId                = Convert.ToInt32(Session["devID"]);
            tbUserCredential user  = db.tbUserCredentials.Where(uc => uc.username.Equals(uName)).Single();
            devViewModel     model = new devViewModel();

            model.tbUser           = user.tbUser;
            model.tbDeveloper      = db.tbDevelopers.Where(d => d.tbClient.tbUser.userID == user.userID).FirstOrDefault();
            model.Proposals        = model.tbDeveloper.tbProposals.ToList();
            model.tbAwardedModules = db.tbAwardedModules.Where(aw => aw.devID == dId).ToList();

            return(View(model));
        }
Пример #3
0
        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));
        }
Пример #4
0
        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));
        }
Пример #5
0
        public ActionResult Login(userViewModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.LoginModel.UserName, model.LoginModel.Password, persistCookie: model.LoginModel.RememberMe))
            {
                string           username       = model.LoginModel.UserName;
                var              query          = from a in db.tbUserCredentials where a.username.Contains(username) select a.userID;
                tbUserCredential userCredential = db.tbUserCredentials.Where(uc => uc.username.Equals(username)).Single();
                var              cUserID        = userCredential.userID;

                //var queryaccType = from a in db.tbUsers where a.userID.Equals(cUserID) select a.accountType;
                //userCredential.tbUser.accountType;
                string accType = userCredential.tbUser.accountType;



                if (accType.Equals("PM"))
                {
                    Session["PM"]     = model.LoginModel.UserName;
                    Session["pmID"]   = cUserID;
                    Session["PMname"] = userCredential.tbUser.firstName + " " + userCredential.tbUser.lastName;
                    return(RedirectToAction("Home", "PM"));
                }
                else if (accType.Equals("Developer"))
                {
                    Session["dev"]     = model.LoginModel.UserName;
                    Session["devID"]   = cUserID;
                    Session["devname"] = userCredential.tbUser.firstName + " " + userCredential.tbUser.lastName;
                    var    dev    = from a in db.tbClients where a.userID.Equals(cUserID) select a;
                    string isComp = dev.FirstOrDefault().isProfileComplete;

                    if (isComp.Equals("Yes"))
                    {
                        return(RedirectToAction("Home", "Developer"));
                    }
                    else if (isComp.Equals("No"))
                    {
                        string action = dev.FirstOrDefault().actionCont;
                        try
                        {
                            int skillID = dev.FirstOrDefault().tbDevelopers.FirstOrDefault().tbSkills.FirstOrDefault().skillID;
                            return(RedirectToAction(action, "Developer", new { id = skillID }));
                        }
                        catch
                        {
                            return(RedirectToAction(action, "Developer"));
                        }
                    }
                }
                else if (accType.Equals("RA"))
                {
                    Session["RA"]     = model.LoginModel.UserName;
                    Session["raID"]   = cUserID;
                    Session["RAname"] = userCredential.tbUser.firstName + " " + userCredential.tbUser.lastName;
                    return(RedirectToAction("Home", "RequirementEngineer"));
                }
                else if (accType.Equals("QA"))
                {
                    Session["QA"]     = model.LoginModel.UserName;
                    Session["qaID"]   = cUserID;
                    Session["QAname"] = userCredential.tbUser.firstName + " " + userCredential.tbUser.lastName;
                    return(RedirectToAction("Home", "QualityAssurance"));
                }
            }

            // If we got this far, something failed, redisplay form

            ModelState.AddModelError("", "The username or password is incorrect.");
            return(View());
        }
Пример #6
0
        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));
        }
Пример #7
0
        public ActionResult Home()
        {
            tbUserCredential model = db.tbUserCredentials.Where(u => u.username.Equals(WebSecurity.CurrentUserName)).FirstOrDefault();

            return(View(model.tbUser));
        }