public ActionResult AddEntryToTicket([Bind(/*Exclude = "DescriptionName,OrcaUserName,EntryDTStamp",*/ Include = "TicketID,EntryText")] AddEntryToTicket entryToAddToTicket)
        {
            OrcaContext db = new OrcaContext();

            // the shit gives probs
            if (ModelState.IsValid)
            {
                DateTime dt = DateTime.Now;

                TicketEntry ticketEntryToCopyToDb = new TicketEntry();

                ticketEntryToCopyToDb.TicketID = entryToAddToTicket.TicketID;
                //ticketEntryToCopyToDb.OrcaUserID = int.Parse(Session["OrcaUserID"].ToString());
                ticketEntryToCopyToDb.OrcaUserID   = Convert.ToInt32(Session["OrcaUserID"].ToString());
                ticketEntryToCopyToDb.EntryDTStamp = dt;
                ticketEntryToCopyToDb.EntryText    = entryToAddToTicket.NewTicketEntry;

                ////System.Diagnostics.Debug.WriteLine(ticketEntryToCopyToDb.TicketID);
                ////System.Diagnostics.Debug.WriteLine(ticketEntryToCopyToDb.OrcaUserID);
                ////System.Diagnostics.Debug.WriteLine(ticketEntryToCopyToDb.EntryDTStamp);
                ////System.Diagnostics.Debug.WriteLine(ticketEntryToCopyToDb.EntryText);


                db.TicketEntries.Add(ticketEntryToCopyToDb);
                db.SaveChanges();

                RedirectToAction("EditConsultationTicket", new { entryToAddToTicket.TicketID, id = entryToAddToTicket.TicketID });
            }



            return(View(entryToAddToTicket));
        }
Exemple #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));
        }
Exemple #3
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 AddConToTic(int id, int ticketId)
        {
            OrcaContext db = new OrcaContext();

            List <TicketExpert> ticketExperts = db.TicketExperts.Where(ticEx => ticEx.TicketID == ticketId).ToList();

            if (ticketExperts.Any(tic => tic.ExpertForThisTicket == id))
            {
                TicketExpert expToEdit = new TicketExpert();
                int          ticExpId  = ticketExperts.First(ticExp => ticExp.ExpertForThisTicket == id).TicketExpertID;

                expToEdit = db.TicketExperts.Find(ticExpId);

                expToEdit.TicketActivityState = ActivityState.Active;

                db.Entry(expToEdit).State = EntityState.Modified;
                db.SaveChanges();
            }
            else
            {
                TicketExpert ticketExpert = new TicketExpert();
                ticketExpert.TicketID            = ticketId;
                ticketExpert.ExpertForThisTicket = id;
                ticketExpert.TicketActivityState = ActivityState.Active;// need to change

                db.TicketExperts.Add(ticketExpert);
                db.SaveChanges();
            }

            return(RedirectToAction("EditConsulTationTicket", new { ticketId = ticketId }));
        }
        public ActionResult Reply([Bind(Include = "TicketID,ReplyText")] ReplyToConsultationTicket reply)
        {
            OrcaContext db = new OrcaContext();

            if (ModelState.IsValid)
            {
                TicketEntry newTicketEntry = new TicketEntry();

                //int oid = int.Parse(Session["OrcaUserID"].ToString());
                int      oid = Convert.ToInt32(Session["OrcaUserID"].ToString());
                DateTime dt  = DateTime.Now;

                newTicketEntry.TicketID     = reply.TicketID;
                newTicketEntry.OrcaUserID   = oid;
                newTicketEntry.EntryDTStamp = dt;
                newTicketEntry.EntryText    = reply.ReplyText;

                db.TicketEntries.Add(newTicketEntry);
                db.SaveChanges();



                return(RedirectToAction("Index"));
            }
            return(View(reply));
        }
        public ActionResult ChangePassword([Bind(Include = "CurrentPassword,Password,ConfirmPassword")] PasswordChange passwordChange)
        {
            // convnention for making it easier to pass messages between controllers
            if (TempData["Message"] != null)
            {
                ViewBag.Message += (" " + TempData["Message"].ToString());
            }

            OrcaContext db = new OrcaContext();

            if (ModelState.IsValid)
            {
                // change password for logged in user and get the success status
                PasswordChangeStatus status = OrcaHelper.ChangePassword(Convert.ToInt32(Session["OrcaUserID"].ToString()), passwordChange);

                switch (status)
                {
                case PasswordChangeStatus.SUCCESS:
                    ViewBag.Message += " Your password has been changed.";
                    break;

                case PasswordChangeStatus.INVALID_PASSWORD:
                    ViewBag.Message += " The Current Password you entered was incorrect. Please try again";
                    break;

                case PasswordChangeStatus.INVALID_USER:
                default:
                    ViewBag.Message += " Something went wrong. This may suggest an Invalid User login.";
                    break;
                }
            }
            return(View());
        }
Exemple #7
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));
        }
        public ActionResult EditConsultationTicket(int ticketId, string searchString)
        {
            // convnention for making it easier to pass messages between controllers
            if (TempData["Message"] != null)
            {
                ViewBag.Message += (" " + TempData["Message"].ToString());
            }

            OrcaContext db = new OrcaContext();

            EditConsultationTicket ticketToEdit = new Models.EditConsultationTicket(ticketId);// this is the ticket we will edit


            //Ticket tick = db.Tickets.Find(ticketId);

            //ticketToEdit.TicketID = ticketId;

            //ticketToEdit.OrcaUserName = Session["OrcaUserName"].ToString();
            //ticketToEdit.DTStamp = tick.DTStamp;
            //ticketToEdit.DescriptionName = tick.DescriptionName;
            //ticketToEdit.IsTicketOpen = tick.IsTicketOpen ? TicketStatus.Open : TicketStatus.Closed;
            //ticketToEdit.NewTicketEntry = "";
            //ticketToEdit.CurrentTicketExperts = ;
            //ticketToEdit.ExpertsToAdd = ;
            //ticketToEdit.TicketEntries = ;



            return(View(ticketToEdit));
        }
Exemple #9
0
        public ActionResult PendingExpertRequests()
        {
            OrcaContext db = new OrcaContext();

            //   List<PendingExpertRequest> pendingRequests
            List <ExpertConsultant> pendingRequests = (from pen in db.ExpertConsultants
                                                       where pen.ExpertStatus == ExpertStatus.Requested
                                                       select pen).ToList();

            List <PendingExpertRequest> pendingExpertRequests = new List <PendingExpertRequest>();

            foreach (ExpertConsultant per in pendingRequests)
            {
                PendingExpertRequest userRequesting = new PendingExpertRequest();

                int oid = per.OrcaUserID;

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

                userRequesting.OrcaUserID   = oid;
                userRequesting.OrcaUserName = ou.OrcaUserName;
                userRequesting.FirstName    = ou.FirstName;
                userRequesting.LastName     = ou.LastName;
                userRequesting.Email        = ou.Email;
                userRequesting.PhoneNumber  = ou.PhoneNumber;

                pendingExpertRequests.Add(userRequesting);
            }

            return(View(pendingExpertRequests));
        }
Exemple #10
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());
        }
        public ActionResult RemoveConsultantFromTicket(int consultantId, int ticketId)
        {
            ////System.Diagnostics.Debug.WriteLine("consultantId = " + consultantId + " | ticketId = " + ticketId);

            OrcaContext db = new OrcaContext();

            // find the ticket expert associated with the ticket
            TicketExpert gettingId = (from exp in db.TicketExperts
                                      where exp.ExpertForThisTicket == consultantId && exp.TicketID == ticketId
                                      select exp).First();
            int ticexpid = gettingId.TicketExpertID;

            TicketExpert expertToRemove = db.TicketExperts.Find(ticexpid);

            // disable expert on this ticket
            if (expertToRemove != null)
            {
                expertToRemove.TicketActivityState = ActivityState.Inactive;

                // update database update db
                db.Entry(expertToRemove).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(RedirectToAction("EditConsultationTicket", new { ticketId, id = ticketId }));
        }
Exemple #12
0
        public static PasswordChangeStatus ChangePassword(int OrcaUserID, PasswordChange passwordChange)
        {
            OrcaContext  db = new OrcaContext();
            OrcaPassword userPasswordQuery = null;

            // get the password from Passwords db table
            try
            {
                //OrcaPassword userPasswordQuery = (from user in db.OrcaPasswords
                //                                  where user.OrcaUserID == OrcaUserID
                //                                  select user).First();
                userPasswordQuery = db.OrcaPasswords.AsQueryable().First(user => user.OrcaUserID == OrcaUserID);
            }
            catch (Exception)// if the OrcaUserID could not be found, return INVALID_USER
            {
                return(PasswordChangeStatus.INVALID_USER);
            }

            // make sure the proper original password was entered
            if (userPasswordQuery.Password == passwordChange.CurrentPassword)
            {
                // change the password
                userPasswordQuery.Password = passwordChange.Password;

                // update the database
                db.Entry(userPasswordQuery).State = EntityState.Modified;
                db.SaveChanges();

                return(PasswordChangeStatus.SUCCESS);
            }

            return(PasswordChangeStatus.INVALID_PASSWORD);
        }
Exemple #13
0
        public ActionResult Register([Bind(Include = "OrcaUserName,FirstName,LastName,Email,PhoneNumber,Password,ConfirmPassword")] Registration registrationInfo)
        {
            // convnention for making it easier to pass messages between controllers
            if (TempData["Message"] != null)
            {
                ViewBag.Message += (" " + TempData["Message"].ToString());
            }

            OrcaContext db = new OrcaContext();

            if (ModelState.IsValid)
            {
                var userExistQuery = from user in db.OrcaUsers
                                     where user.OrcaUserName == registrationInfo.OrcaUserName
                                     select user;

                if (userExistQuery.Any() == false)// make sure the username has not been taken
                {
                    OrcaUser newOrcaUser = new OrcaUser();
                    newOrcaUser.OrcaPassword = new OrcaPassword();


                    // newOrcaUser.OrcaUserID = AUTOGENERATED
                    newOrcaUser.OrcaUserName          = registrationInfo.OrcaUserName;
                    newOrcaUser.FirstName             = registrationInfo.FirstName;
                    newOrcaUser.LastName              = registrationInfo.LastName;
                    newOrcaUser.OrcaPassword.Password = registrationInfo.Password;
                    newOrcaUser.Email                = registrationInfo.Email;
                    newOrcaUser.PhoneNumber          = registrationInfo.PhoneNumber;
                    newOrcaUser.IsAccountDeactivated = false;
                    newOrcaUser.UserType             = OrcaUserType.Consultee;

                    db.OrcaUsers.Add(newOrcaUser);
                    db.SaveChanges();

                    // not the best way to do it, but lets get the ID that was created. i havent tested it but i don't think that the OrcaUserID is coppied from the database to the newOrcaUser.OrcaUserID object.
                    newOrcaUser = (from user in db.OrcaUsers
                                   where user.OrcaUserName == registrationInfo.OrcaUserName
                                   select user).First();

                    Session["OrcaUserID"]   = newOrcaUser.OrcaUserID;
                    Session["OrcaUserName"] = newOrcaUser.OrcaUserName;
                    Session["FirstName"]    = newOrcaUser.FirstName;
                    Session["LastName"]     = newOrcaUser.LastName;
                    Session["UserType"]     = newOrcaUser.UserType;


                    TempData["Message"] = "You have successfully created a new account.";


                    return(RedirectToAction("Index", "Consultee"));
                }
                else// if the username has been taken, instruct to choose different username
                {
                    ViewBag.Message = "This User Name has already been taken. Please choose a different User Name for your account.";
                }
            }
            return(View(registrationInfo));
        }
Exemple #14
0
        public ConsultationEntry(int ticketEntryId)
        {
            OrcaContext db = new OrcaContext();

            OrcaUserName = db.TicketEntries.Find(ticketEntryId).OrcaUser.OrcaUserName;
            EntryDTStamp = db.TicketEntries.Find(ticketEntryId).EntryDTStamp;
            EntryText    = db.TicketEntries.Find(ticketEntryId).EntryText;
        }
Exemple #15
0
        public ActionResult DeleteExpertise(int id)
        {
            OrcaContext db = new OrcaContext();

            ConsultantExpertise expertise = db.ConsultantExpertises.Find(id);

            db.ConsultantExpertises.Remove(expertise);
            db.SaveChanges();

            return(RedirectToAction("UserProfile"));
        }
Exemple #16
0
        public ActionResult ChangeExpert(int OrcaUserID)
        {
            OrcaContext db = new OrcaContext();

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

            ChangeExpert expToChange = new ChangeExpert();
            int          oid         = (int)OrcaUserID;

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

            expToChange.UserType = exp.UserType;

            string boolStrng = db.ExpertConsultants.Find(oid).IsActive.ToString().ToLower().Trim();



            if (boolStrng == "true")
            {
                expToChange.IsActive = true;
            }
            else
            {
                expToChange.IsActive = false;
            }

            boolStrng = exp.IsAccountDeactivated.ToString().ToLower().Trim();



            if (boolStrng == "true")
            {
                expToChange.IsAccountDeactivated = true;
            }
            else
            {
                expToChange.IsAccountDeactivated = false;
            }



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


            return(View(expToChange));
        }
Exemple #17
0
        // alternatively, should have called this ConsultsTicketsList

        public ActionResult Consults()
        {
            // I now realize how it works and how it should be done, but a little late
            // al


            // this will list the consultation tickets where the user is consulting
            // and if you click reply you can reply to ticket



            OrcaContext db = new OrcaContext();

            // get user id of consultant to search for tickets where he is actively consulting
            //int idOfConsultant = int.Parse(Session["OrcaUserID"].ToString());
            int idOfConsultant = Convert.ToInt32(Session["OrcaUserID"].ToString());

            // get all TicketExpert to find all tickets that are actively consulting
            List <TicketExpert> ticketExperts = (from ticEx in db.TicketExperts
                                                 where ticEx.ExpertForThisTicket == idOfConsultant && ticEx.TicketActivityState == ActivityState.Active
                                                 select ticEx).ToList();


            // will put info in this list for view
            List <ConsultsTicketForTicketList> consultReply = new List <ConsultsTicketForTicketList>();

            foreach (TicketExpert tex in ticketExperts)
            {
                ConsultsTicketForTicketList conRep = new ConsultsTicketForTicketList();// create element to put in list

                // populate element


                int tid             = tex.TicketID;                    // find the ticket that the expert is on
                int OrcaIdOfCreator = db.Tickets.Find(tid).OrcaUserID; // needed for user name of created by


                conRep.TicketID     = tid;
                conRep.OrcaUserName = db.OrcaUsers.Find(OrcaIdOfCreator).OrcaUserName;
                conRep.DateCreated  = db.Tickets.Find(tid).DTStamp;
                conRep.Description  = db.Tickets.Find(tid).DescriptionName;

                consultReply.Add(conRep);
            }
            consultReply = consultReply.OrderByDescending(x => x.DateCreated).ToList();


            return(View(consultReply));
        }
Exemple #18
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;
                    }
                }
            }
        }
        //public ActionResult AddConList(int ticketId, string sortOrder, string searchString)
        public ActionResult AddCon(int ticketId, string sortOrder, string searchString)
        {
            ViewBag.TicketID     = ticketId;
            ViewBag.SortOrder    = sortOrder;
            ViewBag.SearchString = searchString;


            OrcaContext db = new OrcaContext();

            ActiveExperts hackExperts = new ActiveExperts();

            hackExperts.SortListBy(SortBy.FieldOfExpertise, SortMethod.Ascending);

            List <ActiveExpert> listForOurModel = hackExperts.Experts;

            // now just get rid of any that are already on the ticket

            //List<TicketExpert> ticketExperts = (from ticEx in db.TicketExperts
            //                                    where ticEx.TicketID != ticketId || (ticEx.TicketActivityState != ActivityState.Active)
            //                                    select ticEx).ToList();



            //List<ActiveExpert> finalList = new List<ActiveExpert>();

            //foreach (ActiveExpert ae in listForOurModel)
            //{
            //    var ticketExperts = from ticEx in db.TicketExperts
            //                        where ticEx.ExpertForThisTicket == ae.OrcaUserID && ticEx.TicketActivityState == ActivityState.Active
            //                        select ticEx;
            //    bool keep = true;

            //    foreach (var te in ticketExperts)
            //    {
            //        if (ae.OrcaUserID == te.ExpertForThisTicket)
            //        {
            //            keep = false;
            //            break;
            //        }
            //    }

            //    if (keep) finalList.Add(ae);
            //}


            return(View(listForOurModel));
        }
        public EditConsultationTicket(int ticketId)
        {
            OrcaContext db = new OrcaContext();

            Ticket ticket = db.Tickets.Find(ticketId);

            if (ticket != null)
            {
                //System.Diagnostics.Debug.WriteLine("EditContultationTicket.cs");
                //System.Diagnostics.Debug.WriteLine("ticket is not null");

                TicketID        = ticketId;
                OrcaUserName    = db.OrcaUsers.Find(ticket.OrcaUserID).OrcaUserName;
                DTStamp         = ticket.DTStamp;
                DescriptionName = ticket.DescriptionName;

                if (ticket.IsTicketOpen)
                {
                    IsTicketOpen = TicketStatus.Open;
                }
                else
                {
                    IsTicketOpen = TicketStatus.Closed;
                }



                CurrentTicketExperts = new ActiveExperts();

                CurrentTicketExperts = CurrentTicketExperts.RemoveExpertsNotActiveOnTicket(ticketId);

                //System.Diagnostics.Debug.WriteLine("After RemoveExpertsNotActiveOnTicket  CurrentTicketExperts.Experts.Count = " + CurrentTicketExperts.Experts.Count);


                //ExpertsToAdd = new ActiveExperts();
                //ExpertsToAdd.AddInactiveExpertsThatAreStillActiveOnTicket(ticketID);

                TicketEntries = new List <ConsultationEntry>();

                foreach (var entry in db.Tickets.Find(ticketId).TicketEntries)
                {
                    TicketEntries.Add(new ConsultationEntry(entry.TicketEntryID));
                }
                TicketEntries.OrderByDescending(x => x.EntryDTStamp);
            }
        }
Exemple #21
0
        public ConsultationTicket InitPopulateConsultationTicket(int?ticketId)
        {
            OrcaContext db = new OrcaContext();


            Ticket ticket = db.Tickets.Find(ticketId);

            if (ticket != null)
            {
                this.TicketID              = ticket.TicketID;
                this.OrcaUserName          = ticket.OrcaUserCreator.OrcaUserName;
                this.DTStamp               = ticket.DTStamp;
                this.DescriptionName       = ticket.DescriptionName;
                this.OrcaUserIDLastReplied = ticket.OrcaUserIDLastReplied;
                this.TicketStatus          = ticket.IsTicketOpen ? ConsultationTicketStatus.Open : ConsultationTicketStatus.Closed;
            }
            return(this);
        }
        public ActionResult AddConsultantToTicket(int consultantId, int ticketId, string sortOrder, string searchString)
        {
            OrcaContext db = new OrcaContext();

            List <TicketExpert> ticketExperts = db.TicketExperts.Where(ticEx => ticEx.TicketID == ticketId).ToList();



            //System.Diagnostics.Debug.WriteLine("AddConsultantToTicket ticketExperts.count = " + ticketExperts.Count);



            if (ticketExperts.Any(tic => tic.ExpertForThisTicket == consultantId))
            {
                TicketExpert expToEdit = new TicketExpert();
                int          ticExpId  = ticketExperts.First(ticExp => ticExp.ExpertForThisTicket == consultantId).TicketExpertID;

                expToEdit = db.TicketExperts.Find(ticExpId);

                expToEdit.TicketActivityState = ActivityState.Active;

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

                //System.Diagnostics.Debug.WriteLine("AddConsultantToTicket UDATED expToEdit.TicketActivityState ");
            }
            else
            {
                TicketExpert ticketExpert = new TicketExpert();
                ticketExpert.TicketID            = ticketId;
                ticketExpert.ExpertForThisTicket = consultantId;
                ticketExpert.TicketActivityState = ActivityState.Active;// need to change

                db.TicketExperts.Add(ticketExpert);
                db.SaveChanges();

                //System.Diagnostics.Debug.WriteLine("AddConsultantToTicket ADDED ticketExpert");
            }

            return(RedirectToAction("EditConsulTationTicket", new { ticketId = ticketId }));
        }
Exemple #23
0
        public ActiveExperts RemoveExpertsNotActiveOnTicket(int ticketID)
        {
            OrcaContext         db         = new OrcaContext();
            List <ActiveExpert> newExperts = new List <ActiveExpert>();

            foreach (ActiveExpert actExp in Experts)
            {
                //var ticketExperts = from ticEx in db.TicketExperts
                //                    where ticEx.ExpertForThisTicket == actExp.OrcaUserID
                //                    select ticEx;
                List <TicketExpert> ticketExperts = db.TicketExperts.Where(x => x.ExpertForThisTicket == actExp.OrcaUserID && x.TicketActivityState == ActivityState.Active && x.TicketID == ticketID).ToList();

                if (ticketExperts.Count > 0)
                {
                    newExperts.Add(actExp);
                }
            }

            Experts = newExperts;
            return(this);
        }
Exemple #24
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));
        }
Exemple #25
0
        public ActionResult ConsultsTicketEntryList(int?ticketId)
        {
            OrcaContext db = new OrcaContext();

            // get the ticket that has the information and entries
            Ticket ticketWithEntries = db.Tickets.Find(ticketId);

            List <TicketEntry> ticketEntriesForThisTicket = (from ticEnt in db.TicketEntries
                                                             where ticEnt.TicketID == ticketId
                                                             select ticEnt).ToList();



            List <ConsultTicketEntryForTicketEntryList> listOfentriesToView = new List <ConsultTicketEntryForTicketEntryList>();

            foreach (TicketEntry ticEnt in ticketEntriesForThisTicket)
            {
                // this needs populated so we can add it to the list which will be passed in return statement
                ConsultTicketEntryForTicketEntryList entryToAddToTicketEntryList = new ConsultTicketEntryForTicketEntryList();


                entryToAddToTicketEntryList.TicketEntryID = ticEnt.TicketEntryID;
                entryToAddToTicketEntryList.TicketID      = ticEnt.TicketID;
                entryToAddToTicketEntryList.EntryDTStamp  = ticEnt.EntryDTStamp;
                entryToAddToTicketEntryList.EntryText     = ticEnt.EntryText;
                entryToAddToTicketEntryList.OrcaUserID    = ticEnt.OrcaUserID;

                int    oid  = entryToAddToTicketEntryList.OrcaUserID;
                string name = db.OrcaUsers.Find(oid).OrcaUserName;

                entryToAddToTicketEntryList.OrcaUserNameCreator = name;

                listOfentriesToView.Add(entryToAddToTicketEntryList);
            }
            listOfentriesToView = listOfentriesToView.OrderByDescending(x => x.EntryDTStamp).ToList();


            return(View(listOfentriesToView));
        }
        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());
        }
Exemple #27
0
        public ActionResult Login([Bind(Include = "OrcaUserName,Password")] Login loginInfo)
        {
            // convnention for making it easier to pass messages between controllers
            if (TempData["Message"] != null)
            {
                ViewBag.Message += (" " + TempData["Message"].ToString());
            }

            OrcaContext db = new OrcaContext();

            if (ModelState.IsValid)
            {
                OrcaUser userQuery = null;

                // get the OrcaUser, if it doesn't exist this will throw an exception and userQuery will remain null
                try
                {
                    userQuery = (from user in db.OrcaUsers
                                 where user.OrcaUserName == loginInfo.OrcaUserName
                                 select user).First();
                }
                catch (Exception)
                {
                }

                if (userQuery != null)// check to see if the user account exists
                {
                    userQuery.OrcaPassword = (from user in db.OrcaPasswords
                                              where user.OrcaUserID == userQuery.OrcaUserID
                                              select user).First();
                    // NOTE:
                    // NOTE: Need to hash password later.
                    // NOTE:
                    if (userQuery.OrcaPassword.Password == loginInfo.Password)// check the password
                    {
                        // this is not the best way to do it, but knowledge of the language and api, or lack thereof dictates a sloppy work-around for now
                        Session["OrcaUserID"]   = userQuery.OrcaUserID;
                        Session["OrcaUserName"] = userQuery.OrcaUserName;
                        Session["FirstName"]    = userQuery.FirstName;
                        Session["LastName"]     = userQuery.LastName;
                        Session["UserType"]     = userQuery.UserType;

                        // following might be somewhat more proper but it is a pain in the arse to figure out when you don't know the language well enough and what i have below doesn't seem to work when trying to get the info out of it.  i will note that using tempdata has no problem but then you have to keep saving the tempdata when going between controllers because otherwise it is cleared
                        //Session["UserProfile"] = (new UserProfile(userQuery.OrcaUserID)) as UserProfile;

                        TempData["Message"] = "You have successfully logged into your account.";

                        switch (userQuery.UserType)
                        {
                        case OrcaUserType.Consultee:
                            return(RedirectToAction("Index", "Consultee"));

                        case OrcaUserType.Consultant:
                            return(RedirectToAction("Index", "Consultant"));

                        case OrcaUserType.ConsultantAdmin:
                            return(RedirectToAction("Index", "ConsultantAdmin"));

                        default:
                            break;
                        }
                    }
                }
            }

            loginInfo.Password = "";// clear the password field so they know something was entered incorrectly
            ViewBag.Message    = "The User Name or Password is incorrect.";

            return(View(loginInfo));
        }
        public ActionResult CreateConsultationTicket([Bind(Include = "DescriptionName,DescriptionDetails")] CreateConsultationTicket ticket)
        {
            // convnention for making it easier to pass messages between controllers
            if (TempData["Message"] != null)
            {
                ViewBag.Message += (" " + TempData["Message"].ToString());
            }

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

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

                // make sure the user hasn't already created a ticket with the same name
                if (!db.Tickets.Any(tic => (tic.OrcaUserID == oid && tic.DescriptionName == ticket.DescriptionName)))
                {
                    Ticket      newTicket      = new Ticket();
                    TicketEntry newTicketEntry = new TicketEntry();
                    DateTime    dtStamp        = DateTime.Now;

                    // enter the values for the ticket
                    newTicket.OrcaUserID      = newTicket.OrcaUserIDLastReplied = Convert.ToInt32(Session["OrcaUserID"].ToString());
                    newTicket.DTStamp         = dtStamp;
                    newTicket.DescriptionName = ticket.DescriptionName;
                    newTicket.IsTicketOpen    = true;

                    db.Tickets.Add(newTicket);
                    db.SaveChanges();

                    // enter the values for the first ticket entry
                    newTicketEntry.TicketID     = newTicket.TicketID;
                    newTicketEntry.OrcaUserID   = newTicket.OrcaUserID;
                    newTicketEntry.EntryDTStamp = dtStamp;
                    newTicketEntry.EntryText    = ticket.DescriptionDetails;

                    db.TicketEntries.Add(newTicketEntry);
                    db.SaveChanges();


                    return(RedirectToAction("EditConsultationTicket", new { newTicket.TicketID, id = newTicket.TicketID }));

                    // DOUBLE NOTE: Leaving this here for now, this was annoying and still doesn't work as I would like it, or maybe it does.
                    // NOTE: The following RedirectToAction takes me to the right url but the id value is null so I will pass it in TempData and pick it up in the EditConsultationTicket
                    // NOTE: Need to do this differently, but will have to do this workaround for now. I think the RoutConfig.cs needs to be edited in App_Start but I'm not sure.

                    //TempData["TicketID"] = newTicket.TicketID;

                    //return RedirectToAction("EditConsultationTicket", new { id = newTicket.TicketID } );
                    //("EditConsultationTicket", new RouteValueDictionary( new { Controller = "Consultee", Action = "EditConsultationTicket", Id = newTicket.TicketID }));//

                    //// the following seems to mostly work as needed, but there is something odd
                    //int id = newTicket.TicketID;
                    //return RedirectToAction("EditConsultationTicket", new { id = id , newTicket.TicketID} );
                    //// the above seems to mostly work as needed, but there is something odd
                    //int id = newTicket.TicketID;
                    //return RedirectToAction("EditConsultationTicket", new { newTicket.TicketID, id = id });
                }
                else
                {
                    ViewBag.Message += "You have previously created a ticket with the same Short Description/Name.  Please, either edit that ticket or change the Short Discription/Name of the new consultation ticket.";
                }
            }

            return(View(ticket));
        }
Exemple #29
0
        public ActiveExperts FilterList(string searchString)
        {
            if (!(String.IsNullOrEmpty(searchString) || String.IsNullOrWhiteSpace(searchString)))
            {
                // not the best way to do it, but it will work for now
                OrcaContext db = new OrcaContext();

                List <ActiveExpert> expertsToKeep = new List <ActiveExpert>();// will contain the filtered list of experts

                // check current list of experts
                foreach (var expert in Experts)
                {
                    bool keep = false;// don't keep the expert unless we find matching substring

                    // check their expertises for a match
                    var checkExpertises = from expertise in db.ConsultantExpertises
                                          where expertise.OrcaUserID == expert.OrcaUserID
                                          select expertise;

                    foreach (var chk in checkExpertises)
                    {
                        if (!String.IsNullOrEmpty(chk.FieldOfExpertise))
                        {
                            if (chk.FieldOfExpertise.ToLower().Contains(searchString.ToLower()))
                            {
                                keep = true;// the expert is a keeper so quick checking
                                break;
                            }
                        }
                    }

                    if (keep)// if expert is a keeper add to new list and check next expert
                    {
                        expertsToKeep.Add(expert);
                        continue;
                    }

                    // search the experts keyword list
                    var expertConsultant = from exp in db.ExpertConsultants
                                           where exp.OrcaUserID == expert.OrcaUserID
                                           select exp;

                    foreach (var exp in expertConsultant)
                    {
                        if (keep)
                        {
                            continue;      // if a keeper is found then check next expert
                        }
                        if (!String.IsNullOrEmpty(exp.KeyWordList))
                        {
                            if (exp.KeyWordList.ToLower().Contains(searchString.ToLower()))
                            {
                                keep = true;
                            }
                        }


                        if (!String.IsNullOrEmpty(exp.TitleDegree))
                        {
                            if (exp.TitleDegree.ToLower().Contains(searchString.ToLower()))
                            {
                                keep = true;
                            }
                        }
                    }

                    if (keep)
                    {
                        expertsToKeep.Add(expert);
                    }
                }
                // set new list
                Experts = expertsToKeep;
            }
            else
            {
                PopulateList();
            }

            return(this);
        }
Exemple #30
0
        ////private void FilterConsultationTickets()
        ////{
        ////    OrcaContext db = new OrcaContext();

        ////    List<ConsultationTicket> newConsultationTickets = new List<ConsultationTicket>();// will replcase current list



        ////    // first create a list of consultation tickets depending on user view // this will become newConsultationTickets
        ////    switch (this.UserViewAccess)
        ////    {
        ////        case UserAccessType.Consultee:

        ////            // Tickets that have OrcaUserID = OrcOrcaUserID_or_TicketExpertID
        ////            //              db.Tickets.Where(x => x.OrcaUserID == OrcaUserID_or_TicketExpertID)
        ////            List<Ticket> ticketsCreatedByUser = new List<Ticket>();
        ////            List<Ticket> tickets = db.Tickets.Where(x => x.OrcaUserID == OrcaUserID_or_TicketExpertID).ToList();

        ////            // create a corresponding ConsultationTicket and add it to newConsulationTickets
        ////            foreach (Ticket tic in tickets)
        ////            {
        ////                ConsultationTicket consultationTicket = new ConsultationTicket(tic.TicketID);// create ConsulationTicket
        ////                if (!newConsultationTickets.Contains(consultationTicket))// make sure not to add duplicates
        ////                    newConsultationTickets.Add(consultationTicket);// add it to newConsulationTickets
        ////            }
        ////            break;
        ////        case UserAccessType.Consultant:
        ////            // TicketExperts that have ExpertForThisTicket = OrcOrcaUserID_or_TicketExpertID
        ////            //              db.TicketExperts.Where(x => x.ExpertForThisTicket == OrcaUserID_or_TicketExpertID)
        ////            List<TicketExpert> ticketExpertsWhereUserIsConsultingOnTicket = new List<TicketExpert>();
        ////            List<TicketExpert> experts = db.TicketExperts.Where(x => x.ExpertForThisTicket == OrcaUserID_or_TicketExpertID).ToList();

        ////            foreach (TicketExpert tex in experts)
        ////            {
        ////                ConsultationTicket consultationTicket = new ConsultationTicket(tex.TicketID);// create ConsultationTicket

        ////                if (!newConsultationTickets.Contains(consultationTicket))// make sure not to add duplicates
        ////                    newConsultationTickets.Add(consultationTicket);// add it to newConsultationTickets
        ////            }
        ////            break;
        ////    }

        ////    this.ConsultationTickets = newConsultationTickets;

        ////}

        public Consultation RefreshConsultationTickets()
        {
            //           FilterConsultationTickets();
            //           SortConsultationTickets();
            //           SearchConsultationTickets();


            OrcaContext db = new OrcaContext();

            List <Ticket> tickets = new List <Ticket>();// the list of tickets that will replace ConsultationTickets


            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Now filter list
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////

            ////////////////////////     SELECT TICKETS FROM DATABASE       /////////////////////////////
            switch (UserViewAccess)
            {
            /////////////////////////////////////////////////   Consultee   //////////////////////////////////////////
            case UserAccessType.Consultee:
                switch (FilterTicketsOption)
                {
                //case TicketFilterOption.All:// all tickets created by user
                //    tickets = db.Tickets.Where(x =>
                //            x.OrcaUserID == OrcaUserID_or_TicketExpertID).ToList();
                //    break;

                case TicketFilterOption.Open:        // tickets created by user && tickets that are open
                    tickets = db.Tickets.Where(x =>
                                               x.OrcaUserID == OrcaUserID_or_TicketExpertID &&
                                               x.IsTicketOpen).ToList();
                    break;

                case TicketFilterOption.Closed:        // tickets created by user && tickets that are not open
                    tickets = db.Tickets.Where(x => x.OrcaUserID == OrcaUserID_or_TicketExpertID && !(x.IsTicketOpen)).ToList();
                    break;

                case TicketFilterOption.NewReply:        // tickets created by users && tickets that are open && tickets where last reply was not the creator
                    tickets = db.Tickets.Where(x => x.OrcaUserID == OrcaUserID_or_TicketExpertID && x.IsTicketOpen && x.OrcaUserIDLastReplied != OrcaUserID_or_TicketExpertID).ToList();
                    break;

                default:        // all tickets created by user
                    tickets = db.Tickets.Where(x => x.OrcaUserID == OrcaUserID_or_TicketExpertID).ToList();
                    break;
                }
                break;

            ////////////////////////////////////////////////////   Consultants   ////////////////////////////////////////////////
            case UserAccessType.Consultant:
                switch (FilterTicketsOption)
                {
                case TicketFilterOption.All:        // this follows the path   Tickets -> TicketExperts.ITEM
                    tickets = db.Tickets.Where(x =>
                                               x.TicketExperts.Where(y => y.ExpertForThisTicket == OrcaUserID_or_TicketExpertID).FirstOrDefault().ExpertForThisTicket == OrcaUserID_or_TicketExpertID).ToList();
                    break;

                case TicketFilterOption.Open:        // this follows the paths   Tickets.ITEM   &&   Tickets -> TicketExperts.ITEM
                    tickets = db.Tickets.Where(x =>
                                               x.IsTicketOpen &&
                                               x.TicketExperts.Where(y => y.ExpertForThisTicket == OrcaUserID_or_TicketExpertID).FirstOrDefault().ExpertForThisTicket == OrcaUserID_or_TicketExpertID).ToList();
                    break;

                case TicketFilterOption.Closed:        // this follows the paths   Tickets.ITEM   &&   Tickets -> TicketExperts.ITEM
                    tickets = db.Tickets.Where(x =>
                                               !x.IsTicketOpen &&
                                               x.TicketExperts.Where(y => y.ExpertForThisTicket == OrcaUserID_or_TicketExpertID).FirstOrDefault().ExpertForThisTicket == OrcaUserID_or_TicketExpertID).ToList();
                    break;

                case TicketFilterOption.NewReply:        // this follows the paths   Tickets.ITEM   &&   Tickets.ITEM   &&   Tickets -> TicketExperts.ITEM
                    tickets = db.Tickets.Where(x =>
                                               x.IsTicketOpen &&
                                               x.OrcaUserIDLastReplied != OrcaUserID_or_TicketExpertID &&
                                               x.TicketExperts.Where(y => y.ExpertForThisTicket == OrcaUserID_or_TicketExpertID).FirstOrDefault().ExpertForThisTicket == OrcaUserID_or_TicketExpertID).ToList();
                    break;

                default:        // this follows the path   Tickets -> TicketExperts.ITEM
                    tickets = db.Tickets.Where(x =>
                                               x.TicketExperts.Where(y => y.ExpertForThisTicket == OrcaUserID_or_TicketExpertID).FirstOrDefault().ExpertForThisTicket == OrcaUserID_or_TicketExpertID).ToList();
                    break;
                }
                break;

            default:
                break;
            }
            //////////////////////////////////////////         END SELECT TICKETS FROM DATABASE  //////////////////////

            //  We have the tickets now search them
            ConsultationTickets = new List <ConsultationTicket>();

            // Now create ConsultationTicket objects for all of the Ticket objects in the list
            foreach (Ticket tic in tickets)
            {
                ConsultationTicket conTicToAdd = new ConsultationTicket(tic.TicketID);
                conTicToAdd.InitPopulateConsultationTicket(tic.TicketID);

                ConsultationTickets.Add(conTicToAdd);// add the ConsultationTicket to the ConsultationTickets list
            }
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // List is filtered
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Now sort list
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////

            switch (SortTicketsOption)
            {
            case TicketSortOption.TicketID:
                this.ConsultationTickets.OrderBy(x => x.TicketID).ToList();
                break;

            case TicketSortOption.OrcaUserName:
                this.ConsultationTickets.OrderBy(x => x.OrcaUserName).ToList();
                break;

            case TicketSortOption.OrcaUserNameLastReplied:
                this.ConsultationTickets.OrderBy(x => x.OrcaUserNameLastReplied).ToList();
                break;

            case TicketSortOption.DTStamp:
                this.ConsultationTickets.OrderBy(x => x.DTStamp).ToList();
                break;

            case TicketSortOption.DescriptionName:
                this.ConsultationTickets.OrderBy(x => x.DescriptionName).ToList();
                break;

            case TicketSortOption.TicketStatus:
                this.ConsultationTickets.OrderBy(x => x.TicketStatus).ToList();
                break;

            case TicketSortOption.TicketID_desc:
                this.ConsultationTickets.OrderByDescending(x => x.TicketID).ToList();
                break;

            case TicketSortOption.OrcaUserName_desc:
                this.ConsultationTickets.OrderByDescending(x => x.OrcaUserName).ToList();
                break;

            case TicketSortOption.OrcaUserNameLastReplied_desc:
                this.ConsultationTickets.OrderByDescending(x => x.OrcaUserNameLastReplied).ToList();
                break;

            case TicketSortOption.DTStamp_desc:
                this.ConsultationTickets.OrderByDescending(x => x.DTStamp).ToList();
                break;

            case TicketSortOption.DescriptionName_desc:
                this.ConsultationTickets.OrderByDescending(x => x.DescriptionName).ToList();
                break;

            case TicketSortOption.TicketStatus_desc:
                this.ConsultationTickets.OrderByDescending(x => x.TicketStatus).ToList();
                break;

            default:
                this.ConsultationTickets.OrderByDescending(x => x).ToList();
                break;
            }

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // List is sorted
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Now search list and discard non-matches
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////

            List <ConsultationTicket> consultationTicketsToKeep = new List <ConsultationTicket>();// this will be the new ConsultationTickets list

            //if (this.UserViewAccess = UserAccessType.Consultee)
            foreach (ConsultationTicket ticket in ConsultationTickets)
            {
                int tid = ticket.TicketID;

                // search description name of ticket
                if (db.Tickets.Find(tid).DescriptionName.Contains(this.TicketSearchString))
                {
                    consultationTicketsToKeep.Add(ticket);
                    continue;
                }

                // search ticket entries
                var ticketEntriesQuery = from tick in db.TicketEntries
                                         where tick.TicketID == ticket.TicketID
                                         select tick;

                foreach (var tick in ticketEntriesQuery)
                {
                    consultationTicketsToKeep.Add(ticket);
                    break;
                }
            }
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // List is searched and only contains matches
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //////////////////////////////////////////////////////////////////////////////////////////////////////////////

            return(this);
        }