Esempio n. 1
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));
        }
Esempio n. 2
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());
        }
Esempio n. 3
0
        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 }));
        }
Esempio n. 4
0
        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 }));
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
 public ActionResult Edit([Bind(Include = "OrcaUserID,OrcaUserName,FirstName,LastName,Email,PhoneNumber,IsAccountDeactivated,UserType")] OrcaUser orcaUser)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orcaUser).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(orcaUser));
 }
 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));
 }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "OrcaUserID,Password")] OrcaPassword orcaPassword)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orcaPassword).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", orcaPassword.OrcaUserID);
     return(View(orcaPassword));
 }
 public ActionResult Edit([Bind(Include = "TicketEntryID,TicketID,OrcaUserID,EntryDTStamp,EntryText")] TicketEntry ticketEntry)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketEntry).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", ticketEntry.OrcaUserID);
     ViewBag.TicketID   = new SelectList(db.Tickets, "TicketID", "DescriptionName", ticketEntry.TicketID);
     return(View(ticketEntry));
 }
 public ActionResult Edit([Bind(Include = "TicketID,OrcaUserID,OrcaUserIDLastReplied,DTStamp,DescriptionName,IsTicketOpen")] Ticket ticket)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticket).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrcaUserID            = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", ticket.OrcaUserID);
     ViewBag.OrcaUserIDLastReplied = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", ticket.OrcaUserIDLastReplied);
     return(View(ticket));
 }
 public ActionResult Edit([Bind(Include = "ConsultantExpertiseID,OrcaUserID,FieldOfExpertise")] ConsultantExpertise consultantExpertise)
 {
     if (ModelState.IsValid)
     {
         db.Entry(consultantExpertise).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrcaUserID = new SelectList(db.ExpertConsultants, "OrcaUserID", "TitleDegree", consultantExpertise.OrcaUserID);
     ViewBag.OrcaUserID = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", consultantExpertise.OrcaUserID);
     return(View(consultantExpertise));
 }
Esempio n. 12
0
 public ActionResult Edit([Bind(Include = "TicketExpertID,TicketID,ExpertForThisTicket,TicketActivityState")] TicketExpert ticketExpert)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ticketExpert).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ExpertForThisTicket = new SelectList(db.ExpertConsultants, "OrcaUserID", "TitleDegree", ticketExpert.ExpertForThisTicket);
     ViewBag.ExpertForThisTicket = new SelectList(db.OrcaUsers, "OrcaUserID", "OrcaUserName", ticketExpert.ExpertForThisTicket);
     ViewBag.TicketID            = new SelectList(db.Tickets, "TicketID", "DescriptionName", ticketExpert.TicketID);
     return(View(ticketExpert));
 }
Esempio n. 13
0
        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 }));
        }
Esempio n. 14
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);
        }