예제 #1
0
        public ActionResult CurrentExperts()
        {
            OrcaContext db = new OrcaContext();

            List <ChangeExpert> experts = new List <ChangeExpert>();


            List <OrcaUser> expertUsers = db.OrcaUsers.Where(x => x.UserType == OrcaUserType.Consultant).ToList();

            foreach (OrcaUser exp in expertUsers)
            {
                int oid = exp.OrcaUserID;
                ExpertConsultant expCon = db.ExpertConsultants.Find(oid);

                ChangeExpert expToChange = new ChangeExpert();

                expToChange.OrcaUserID   = oid;
                expToChange.OrcaUserName = exp.OrcaUserName;


                expToChange.IsActive = expCon.IsActive;

                expToChange.IsAccountDeactivated = exp.IsAccountDeactivated;


                expToChange.FirstName   = exp.FirstName;
                expToChange.LastName    = exp.LastName;
                expToChange.Email       = exp.Email;
                expToChange.PhoneNumber = exp.PhoneNumber;

                experts.Add(expToChange);
            }

            return(View(experts));
        }
예제 #2
0
        public ActionResult PendingExpertRequestDetails([Bind(Exclude = "OrcaUserName,FirstName,LastName,Email,PhoneNumber", Include = "OrcaUserID, ExpertStatus")] PendingExpertRequest pendingExpertRequest)
        {
            int oid = pendingExpertRequest.OrcaUserID;

            if (ModelState.IsValid)
            {
                OrcaContext db = new OrcaContext();

                ExpertConsultant expToUpdate = db.ExpertConsultants.Find(pendingExpertRequest.OrcaUserID);

                expToUpdate.ExpertStatus = pendingExpertRequest.ExpertStatus;

                db.Entry(expToUpdate).State = EntityState.Modified;
                db.SaveChanges();


                //OrcaUserType.Consultant
                if (pendingExpertRequest.ExpertStatus == ExpertStatus.Approved)
                {
                    OrcaUser requestingUser = db.OrcaUsers.Find(pendingExpertRequest.OrcaUserID);

                    requestingUser.UserType = OrcaUserType.Consultant;

                    db.Entry(requestingUser).State = EntityState.Modified;
                    db.SaveChanges();
                }


                return(RedirectToAction("PendingExpertRequests"));
            }


            return(View(pendingExpertRequest));
        }
예제 #3
0
        public ActionResult ChangeExpert([Bind(Exclude = "OrcaUserName,FirstName,LastName,Email,PhoneNumber", Include = "OrcaUserID,UserType,IsActive,IsAccountDeactivated")] ChangeExpert expToChange)
        {
            if (ModelState.IsValid)
            {
                OrcaContext db  = new OrcaContext();
                int         oid = expToChange.OrcaUserID;

                OrcaUser changeUser = db.OrcaUsers.Find(oid);

                changeUser.UserType             = expToChange.UserType;
                changeUser.IsAccountDeactivated = expToChange.IsAccountDeactivated;

                db.Entry(changeUser).State = EntityState.Modified;
                db.SaveChanges();

                ExpertConsultant expCon = db.ExpertConsultants.Find(oid);

                expCon.IsActive = expToChange.IsActive;

                db.Entry(expCon).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("CurrentExperts"));
            }

            return(View());
        }
예제 #4
0
        public ActiveExperts PopulateList()
        {
            OrcaContext db = new OrcaContext();

            // THIS IS A NASTY HACK BUT IT WILL WORK FOR NOW, it assumes that an expert consultant has added an expertise, otherwise the consultant can not be found in the list
            // NOTE: I need to figure out how to do the following section properly. I believe it has to do with using join, but I don't know enough about it so this will suffice for now.
            List <ConsultantExpertise> consultantExpertises = db.ConsultantExpertises.ToList();

            Experts = new List <ActiveExpert>();

            foreach (var exp in consultantExpertises)
            {
                ExpertConsultant expertConsultant = db.ExpertConsultants.Find(exp.OrcaUserID);

                if (expertConsultant != null && expertConsultant.IsActive)
                {
                    OrcaUser     orcaUser     = db.OrcaUsers.Find(exp.OrcaUserID);
                    ActiveExpert activeExpert = new ActiveExpert();

                    activeExpert.OrcaUserID       = exp.OrcaUserID;
                    activeExpert.OrcaUserName     = orcaUser.OrcaUserName;
                    activeExpert.FirstName        = orcaUser.FirstName;
                    activeExpert.LastName         = orcaUser.LastName;
                    activeExpert.TitleDegree      = expertConsultant.TitleDegree;
                    activeExpert.FieldOfExpertise = exp.FieldOfExpertise;

                    Experts.Add(activeExpert);
                }
            }
            // NOTE: Need to figure out how to do the above section properly. I believe it can and should be done with a join but I don't know enough about it and this will suffice for now.
            return(this);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ExpertConsultant expertConsultant = db.ExpertConsultants.Find(id);

            db.ExpertConsultants.Remove(expertConsultant);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "OrcaUserID,ExpertStatus,IsActive,TitleDegree,KeyWordList")] ExpertConsultant expertConsultant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(expertConsultant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", expertConsultant.OrcaUserID);
     return(View(expertConsultant));
 }
        // GET: zzzTESTinCASEExpertConsultants/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExpertConsultant expertConsultant = db.ExpertConsultants.Find(id);

            if (expertConsultant == null)
            {
                return(HttpNotFound());
            }
            return(View(expertConsultant));
        }
        // GET: zzzTESTinCASEExpertConsultants/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExpertConsultant expertConsultant = db.ExpertConsultants.Find(id);

            if (expertConsultant == null)
            {
                return(HttpNotFound());
            }
            ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", expertConsultant.OrcaUserID);
            return(View(expertConsultant));
        }
예제 #9
0
        public UserProfile(int OrcaUserID)
        {
            OrcaContext db = new OrcaContext();

            OrcaUser userInfo = db.OrcaUsers.Find(OrcaUserID);


            if (userInfo != null)
            {
                // fill in the info for the user
                this.OrcaUserID   = OrcaUserID;
                this.OrcaUserName = userInfo.OrcaUserName;
                this.FirstName    = userInfo.FirstName;
                this.LastName     = userInfo.LastName;
                this.Email        = userInfo.Email;
                this.PhoneNumber  = userInfo.PhoneNumber;

                // check to see if user is a consultant expert
                if (userInfo.UserType == OrcaUserType.Consultant || userInfo.UserType == OrcaUserType.ConsultantAdmin)
                {
                    ExpertConsultant consultantInfo = db.ExpertConsultants.Find(OrcaUserID);

                    if (consultantInfo != null)
                    {
                        // using a dropdown but the db value is a bool, so set appropriately
                        if (consultantInfo.IsActive)
                        {
                            this.IsActive = ActiveStatus.Yes;
                        }
                        else
                        {
                            this.IsActive = ActiveStatus.No;
                        }

                        this.TitleDegree = consultantInfo.TitleDegree;

                        // this.FieldsOfExpertise = consultantInfo.ConsultantExpertises;

                        this.FieldsOfExpertise = (from expertise in db.ConsultantExpertises
                                                  where expertise.OrcaUserID == OrcaUserID
                                                  select expertise).OrderBy(x => x.FieldOfExpertise).ToList();


                        this.KeyWordList = consultantInfo.KeyWordList;
                    }
                }
            }
        }
예제 #10
0
        public ActionResult PendingExpertRequestDetails(int?OrcaUserID)
        {
            OrcaContext db = new OrcaContext();

            PendingExpertRequest pendingRequester = new PendingExpertRequest();

            int              oid = (int)OrcaUserID;
            OrcaUser         ou  = db.OrcaUsers.Find(oid);
            ExpertConsultant exp = db.ExpertConsultants.Find(oid);

            ou = db.OrcaUsers.Find(oid);

            pendingRequester.OrcaUserID   = ou.OrcaUserID;
            pendingRequester.ExpertStatus = exp.ExpertStatus;
            pendingRequester.OrcaUserName = ou.OrcaUserName;
            pendingRequester.FirstName    = ou.FirstName;
            pendingRequester.LastName     = ou.LastName;
            pendingRequester.Email        = ou.Email;
            pendingRequester.PhoneNumber  = ou.PhoneNumber;

            return(View(pendingRequester));
        }
예제 #11
0
        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();
        }
예제 #12
0
        public ActionResult ExpertRequest()
        {
            OrcaContext db = new OrcaContext();

            int userId = (int)Convert.ToInt32(Session["OrcaUserID"].ToString());

            //  BOOKMARK
            ExpertConsultant requestingUser = null;// db.ExpertConsultants.Find(userId);

            if (requestingUser == null)
            {
                requestingUser = new ExpertConsultant();
                int oid = Convert.ToInt32(Session["OrcaUserID"].ToString());

                requestingUser.OrcaUserID = db.OrcaUsers.Find(oid).OrcaUserID;

                requestingUser.IsActive     = true;
                requestingUser.ExpertStatus = ExpertStatus.Requested;

                db.ExpertConsultants.Add(requestingUser);
                db.SaveChanges();

                //ConsultantStatusRequest request = db.ConsultantStatusRequests.Find(userId);

                //if (request == null)
                //{
                //    request = new ConsultantStatusRequest();
                //    request.OrcaUserID = userId;
                //    request.RequestingStatus = true;

                //    db.ConsultantStatusRequests.Add(request);
                //    db.SaveChanges();
                //}
                //else
                //{
                //    request.OrcaUserID = userId;
                //    request.RequestingStatus = true;

                //    db.Entry(request).State = EntityState.Modified;
                //    db.SaveChanges();
                //}

                ViewBag.Message = "A request to become a Marshall Expert Consultant has been submitted.  Please make sure that your name and contact information under Profile is accurate. Your request will be reviewed, and an administrator may contact you for further information.  If your request is approved then your account will be promoted.";
            }
            else
            {
                switch (requestingUser.ExpertStatus)
                {
                case ExpertStatus.Requested:
                    ViewBag.Message = "A previous request to become a Marshall Expert Consultant has already been submitted.  Please be patient as the request must be reviewed.";
                    break;

                case ExpertStatus.Declined:
                    ViewBag.Message = "Your previous request to become a Marshall Expert Consultant has been declined.";
                    break;

                case ExpertStatus.Approved:
                    ViewBag.Message = "You have been approved as a Marshall Expert Consultant.  You will need to log out and log back in to access additional features of your new account status.";
                    break;

                default:
                    ViewBag.Message = "An unknown problem has occured and your request cannot be processed at this time.";
                    break;
                }
            }

            return(View());
        }
예제 #13
0
        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);
        }