Beispiel #1
0
        public IEnumerable <StaffCheckViewModel> CanUsePage(string id)
        {
            var _unitOfWork = new UnitOfWork();
            var query       = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == id);

            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The account was not found."
                      };
            }
            var idParam = new SqlParameter("@ID_Num", id);

            var result = RawSqlQuery <StaffCheckViewModel> .StaffTimesheetQuery("staff_timesheets_can_use_this_page @ID_NUM", idParam); // run stored procedure

            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }

            var staffTimesheet = result.Select(x =>
            {
                StaffCheckViewModel y = new StaffCheckViewModel();
                y.EmIID = true;

                return(y);
            });

            return(staffTimesheet);
        }
Beispiel #2
0
        public ClockInViewModel DeleteClockIn(string id)
        {
            var _unitOfWork = new UnitOfWork();
            var query       = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == id);

            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The account was not found."
                      };
            }

            var idParam = new SqlParameter("@ID_Num", id);

            var result = RawSqlQuery <ClockInViewModel> .query("DELETE_CLOCK_IN @ID_NUM", idParam); //run stored procedure


            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }



            ClockInViewModel y = new ClockInViewModel();

            return(y);
        }
Beispiel #3
0
        public ClockInViewModel ClockIn(bool state, string id)
        {
            var _unitOfWork = new UnitOfWork();
            var query       = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == id);

            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The account was not found."
                      };
            }

            var idParam    = new SqlParameter("@ID_Num", id);
            var stateParam = new SqlParameter("@CurrentState", state);

            var result = RawSqlQuery <ClockInViewModel> .query("INSERT_TIMESHEETS_CLOCK_IN_OUT @ID_Num, @CurrentState", idParam, stateParam); //run stored procedure

            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }

            var currentState = state;

            ClockInViewModel y = new ClockInViewModel()
            {
                currentState = currentState
            };

            return(y);
        }
        /// <summary>
        /// Fetch the membership whose id is specified by the parameter
        /// </summary>
        /// <param name="id">The membership id</param>
        /// <returns>MembershipViewModel if found, null if not found</returns>
        public MembershipViewModel Get(int id)
        {
            var query = _unitOfWork.MembershipRepository.GetById(id);

            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The Membership was not found."
                      };
            }

            var idParam = new SqlParameter("@MEMBERSHIP_ID", id);
            var result  = RawSqlQuery <MembershipViewModel> .query("MEMBERSHIPS_PER_MEMBERSHIP_ID @MEMBERSHIP_ID", idParam).FirstOrDefault();

            if (result == null)
            {
                return(null);
            }
            // Getting rid of database-inherited whitespace
            result.ActivityCode             = result.ActivityCode.Trim();
            result.ActivityDescription      = result.ActivityDescription.Trim();
            result.SessionCode              = result.SessionCode.Trim();
            result.SessionDescription       = result.SessionDescription.Trim();
            result.IDNumber                 = result.IDNumber;
            result.FirstName                = result.FirstName.Trim();
            result.LastName                 = result.LastName.Trim();
            result.Participation            = result.Participation.Trim();
            result.ParticipationDescription = result.ParticipationDescription.Trim();

            return(result);
        }
        /// <summary>
        /// Get the membership request object whose Id is specified in the parameters.
        /// </summary>
        /// <param name="id">The membership request id</param>
        /// <returns>If found, returns MembershipRequestViewModel. If not found, returns null.</returns>
        public MembershipRequestViewModel Get(int id)
        {
            var idParameter = new SqlParameter("@REQUEST_ID", id);
            var result      = RawSqlQuery <MembershipRequestViewModel> .query("REQUEST_PER_REQUEST_ID @REQUEST_ID", idParameter).FirstOrDefault();

            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The Request was not found."
                      };
            }

            // Getting rid of database-inherited whitespace
            result.ActivityCode             = result.ActivityCode.Trim();
            result.ActivityDescription      = result.ActivityDescription.Trim();
            result.SessionCode              = result.SessionCode.Trim();
            result.SessionDescription       = result.SessionDescription.Trim();
            result.IDNumber                 = result.IDNumber;
            result.FirstName                = result.FirstName.Trim();
            result.LastName                 = result.LastName.Trim();
            result.Participation            = result.Participation.Trim();
            result.ParticipationDescription = result.ParticipationDescription.Trim();

            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// Fetch the schedule item whose id and session code is specified by the parameter
        /// </summary>
        /// <param name="id">The id of the instructor</param>
        /// <returns>StudentScheduleViewModel if found, null if not found</returns>
        public IEnumerable <ScheduleViewModel> GetScheduleFaculty(string id)
        {
            var query = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == id);

            //var currentSessionCode = Helpers.GetCurrentSession().SessionCode;
            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The Schedule was not found."
                      };
            }

            var currentSessionCode = Helpers.GetCurrentSession().SessionCode;

            // This is a test code for 2019 Summer. Next time you see this, delete this part
            if (currentSessionCode == "201905" && id != "999999099")
            {
                currentSessionCode = "201909";
            }

            //var idInt = Int32.Parse(id);
            var idParam   = new SqlParameter("@instructor_id", id);
            var sessParam = new SqlParameter("@sess_cde", currentSessionCode);
            var result    = RawSqlQuery <ScheduleViewModel> .query("INSTRUCTOR_COURSES_BY_ID_NUM_AND_SESS_CDE @instructor_id, @sess_cde", idParam, sessParam);

            if (result == null)
            {
                return(null);
            }

            return(result);
        }
        /// <summary>
        /// Adds a news item record to storage.
        /// </summary>
        /// <param name="newsItem">The news item to be added</param>
        /// <param name="username">username</param>
        /// <param name="id">id</param>
        /// <returns>The newly added Membership object</returns>
        public StudentNews SubmitNews(StudentNews newsItem, string username, string id)
        {
            // Not currently used
            ValidateNewsItem(newsItem);

            VerifyAccount(id);

            // SQL Parameters
            var usernameParam   = new SqlParameter("@Username", username);
            var categoryIDParam = new SqlParameter("@CategoryID", newsItem.categoryID);
            var subjectParam    = new SqlParameter("@Subject", newsItem.Subject);
            var bodyParam       = new SqlParameter("@Body", newsItem.Body);

            // Run stored procedure
            var result = RawSqlQuery <StudentNewsViewModel> .query("INSERT_NEWS_ITEM @Username, @CategoryID, @Subject, @Body", usernameParam, categoryIDParam, subjectParam, bodyParam);

            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }

            return(newsItem);
        }
        //stores the a users expo token for push notification
        public bool StoreUserConnectionIds(String userId, String connectionId)
        {
            var _unitOfWork = new UnitOfWork();
            var query       = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == userId);

            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The account was not found."
                      };
            }

            var userIdParam       = new SqlParameter("@user_id", userId);
            var connectionIdParam = new SqlParameter("@connection_id", connectionId);


            var result = RawSqlQuery <MessageViewModel> .query("INSERT_USER_CONNECTION_ID @user_id, @connection_id", userIdParam, connectionIdParam); //run stored procedure

            bool returnAnswer = true;

            if (result == null)
            {
                returnAnswer = false;
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }



            return(returnAnswer);
        }
        /// <summary>
        /// get victory promise scores
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>VictoryPromiseViewModel if found, null if not found</returns>
        public IEnumerable<VictoryPromiseViewModel> GetVPScores(string id)
        {
            var query = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == id);
            if (query == null)
            {
                throw new ResourceNotFoundException() { ExceptionMessage = "The account was not found." };
            }

            var idParam = new SqlParameter("@ID", id);
            var result = RawSqlQuery<VictoryPromiseViewModel>.query("VICTORY_PROMISE_BY_STUDENT_ID @ID", idParam); //run stored procedure
            if (result == null)
            {
                throw new ResourceNotFoundException() { ExceptionMessage = "The data was not found." };
            }
            // Transform the ActivityViewModel (ACT_CLUB_DEF) into ActivityInfoViewModel
            var victoryPromiseModel = result.Select(x =>
            {
                VictoryPromiseViewModel y = new VictoryPromiseViewModel();
                y.TOTAL_VP_CC_SCORE = x.TOTAL_VP_CC_SCORE ?? 0;
                y.TOTAL_VP_IM_SCORE = x.TOTAL_VP_IM_SCORE ?? 0;
                y.TOTAL_VP_LS_SCORE = x.TOTAL_VP_LS_SCORE ?? 0;
                y.TOTAL_VP_LW_SCORE = x.TOTAL_VP_LW_SCORE ?? 0;
                return y;
            });
            return victoryPromiseModel;

        }
        /// <summary>
        /// Fetches the advisors of the activity whose activity code is specified by the parameter.
        /// </summary>
        /// <param name="id">The activity code.</param>
        /// <returns>MembershipViewModel IEnumerable. If no records were found, an empty IEnumerable is returned.</returns>
        public IEnumerable <MembershipViewModel> GetAdvisorMembershipsForActivity(string id)
        {
            var idParam = new SqlParameter("@ACT_CDE", id);
            var result  = RawSqlQuery <MembershipViewModel> .query("MEMBERSHIPS_PER_ACT_CDE @ACT_CDE", idParam);

            // Filter advisors

            var advisorRole = Helpers.GetAdvisorRoleCodes();

            result = result.Where(x => advisorRole == x.Participation.Trim());

            // Getting rid of whitespace inherited from the database .__.
            var trimmedResult = result.Select(x =>
            {
                var trim                      = x;
                trim.ActivityCode             = x.ActivityCode.Trim();
                trim.ActivityDescription      = x.ActivityDescription.Trim();
                trim.SessionCode              = x.SessionCode.Trim();
                trim.SessionDescription       = x.SessionDescription.Trim();
                trim.IDNumber                 = x.IDNumber;
                trim.FirstName                = x.FirstName.Trim();
                trim.LastName                 = x.LastName.Trim();
                trim.Participation            = x.Participation.Trim();
                trim.ParticipationDescription = x.ParticipationDescription.Trim();
                return(trim);
            });

            return(trimmedResult);
        }
        //gets a users expo token for push notification
        public List <IEnumerable <ConnectionIdViewModel> > GetUserConnectionIds(List <String> userIds)
        {
            var _unitOfWork = new UnitOfWork();

            foreach (string user in userIds)
            {
                var query = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == user);
                if (query == null)
                {
                    throw new ResourceNotFoundException()
                          {
                              ExceptionMessage = "One of the accounts was not found."
                          };
                }
            }
            var idList = new List <IEnumerable <ConnectionIdViewModel> >(300);

            foreach (string user in userIds)
            {
                var userIdParam = new SqlParameter("@user_id", user);

                var result = RawSqlQuery <ConnectionIdViewModel> .query("GET_ALL_CONNECTION_IDS_BY_ID @user_id", userIdParam); //run stored procedure

                var model = result.Select(x =>
                {
                    ConnectionIdViewModel y = new ConnectionIdViewModel();
                    y.connection_id         = x.connection_id;
                    return(y);
                });

                idList.Add(model);
            }

            return(idList);
        }
        public static JObject GetAllPublicStudents()
        {
            // JSON string result
            IEnumerable <string> fragmentedString = null;
            string  result            = null;
            JObject publicStudentData = null;

            try
            {
                // Attempt to query the DB
                fragmentedString = RawSqlQuery <string> .query(SQLQuery.ALL_PUBLIC_STUDENT_REQUEST).Cast <string>();

                foreach (string fragment in fragmentedString)
                {
                    result = result + fragment;
                }
                publicStudentData = JObject.Parse(result);
            }
            catch (Exception e)
            {
                //
                Debug.WriteLine("Failed to parse JSON data:");
                Debug.WriteLine(e.Message);
            }
            // Filter out results with null or empty active directory names
            return(publicStudentData);
        }
        /// <summary>
        /// Fetches all the membership information linked to the student whose id appears as a parameter.
        /// </summary>
        /// <param name="id">The student id.</param>
        /// <returns>A MembershipViewModel IEnumerable. If nothing is found, an empty IEnumberable is returned.</returns>
        public IEnumerable <MembershipViewModel> GetMembershipsForStudent(string id)
        {
            var studentExists = _unitOfWork.AccountRepository.Where(x => x.gordon_id.Trim() == id).Count() > 0;

            if (!studentExists)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The Account was not found."
                      };
            }

            var idParam = new SqlParameter("@STUDENT_ID", id);
            var result  = RawSqlQuery <MembershipViewModel> .query("MEMBERSHIPS_PER_STUDENT_ID @STUDENT_ID", idParam);

            // The Views that were given to were defined as char(n) instead of varchar(n)
            // They return with whitespace padding which messes up comparisons later on.
            // I'm using the IEnumerable Select method here to help get rid of that.
            var trimmedResult = result.Select(x =>
            {
                var trim                      = x;
                trim.ActivityCode             = x.ActivityCode.Trim();
                trim.ActivityDescription      = x.ActivityDescription.Trim();
                trim.SessionCode              = x.SessionCode.Trim();
                trim.SessionDescription       = x.SessionDescription.Trim();
                trim.Participation            = x.Participation.Trim();
                trim.ParticipationDescription = x.ParticipationDescription.Trim();
                trim.FirstName                = x.FirstName.Trim();
                trim.LastName                 = x.LastName.Trim();
                trim.IDNumber                 = x.IDNumber;
                return(trim);
            });

            return(trimmedResult.OrderByDescending(x => x.StartDate));
        }
        /// <summary>
        /// Fetches the number of memberships associated with the activity whose code is specified by the parameter.
        /// </summary>
        /// <param name="id">The activity code.</param>
        /// <returns>int.</returns>
        public int GetActivityMembersCount(string id)
        {
            var idParam = new SqlParameter("@ACT_CDE", id);
            var result  = RawSqlQuery <MembershipViewModel> .query("MEMBERSHIPS_PER_ACT_CDE @ACT_CDE", idParam);

            return(result.Where(x => x.Participation != "GUEST").Count());
        }
        /// <summary>
        /// Fetches the number of memberships associated with the activity and session whose codes are specified by the parameter.
        /// </summary>
        /// <param name="id">The activity code.</param>
        /// <param name="sess_cde">The session code</param>
        /// <returns>int.</returns>
        public int GetActivityMembersCountForSession(string id, string sess_cde)
        {
            var idParam = new SqlParameter("@ACT_CDE", id);
            var result  = RawSqlQuery <MembershipViewModel> .query("MEMBERSHIPS_PER_ACT_CDE @ACT_CDE", idParam);

            return(result.Where(x => x.Participation != "GUEST" && x.SessionCode.Trim() == sess_cde).Count());
        }
        //returns all the room IDs associated with a user id
        public IEnumerable <GroupViewModel> GetRooms(string userId)
        {
            var userIdParam = new SqlParameter("@user_id", userId);

            var result = RawSqlQuery <GroupViewModel> .query("GET_ALL_ROOMS_BY_ID @user_id", userIdParam); //run stored procedure

            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }


            var GroupModel = result.Select(x =>
            {
                GroupViewModel y = new GroupViewModel();

                y.room_id = x.room_id;

                return(y);
            });


            return(GroupModel);
        }
        /// <summary>
        /// Fetches the group admin (who have edit privileges of the page) of the activity whose activity code is specified by the parameter.
        /// </summary>
        /// <param name="id">The activity code.</param>
        /// <returns>MembershipViewModel IEnumerable. If no records were found, an empty IEnumerable is returned.</returns>
        public IEnumerable <MembershipViewModel> GetGroupAdminMembershipsForActivity(string id)
        {
            var idParam = new SqlParameter("@ACT_CDE", id);
            var result  = RawSqlQuery <MembershipViewModel> .query("MEMBERSHIPS_PER_ACT_CDE @ACT_CDE", idParam);

            // Filter group admin
            result = result.Where(x => x.GroupAdmin.HasValue && x.GroupAdmin.Value == true);
            // Getting rid of whitespace inherited from the database .__.
            var trimmedResult = result.Select(x =>
            {
                var trim                      = x;
                trim.ActivityCode             = x.ActivityCode.Trim();
                trim.ActivityDescription      = x.ActivityDescription.Trim();
                trim.SessionCode              = x.SessionCode.Trim();
                trim.SessionDescription       = x.SessionDescription.Trim();
                trim.IDNumber                 = x.IDNumber;
                trim.FirstName                = x.FirstName.Trim();
                trim.LastName                 = x.LastName.Trim();
                trim.Participation            = x.Participation.Trim();
                trim.ParticipationDescription = x.ParticipationDescription.Trim();
                return(trim);
            });

            return(trimmedResult);
        }
        /// <summary>
        /// gets the question for the wellness check from the back end
        /// </summary>
        /// <returns>list of strings with questions and prompts</returns>

        public IEnumerable <WellnessQuestionViewModel> GetQuestion()
        {
            var result = RawSqlQuery <WellnessQuestionViewModel> .query("GET_HEALTH_CHECK_QUESTION"); //run stored procedure


            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }


            var wellnessQuestionModel = result.Select(x =>
            {
                WellnessQuestionViewModel y = new WellnessQuestionViewModel();

                y.question = x.question;

                y.yesPrompt = x.yesPrompt;

                y.noPrompt = x.noPrompt;

                return(y);
            });



            return(wellnessQuestionModel);
        }
        /// <summary>
        /// gets status of wellness check
        /// </summary>
        /// <param name="id">id</param>
        /// <returns>boolean if found, null if not found</returns>

        public IEnumerable <WellnessViewModel> GetStatus(string id)
        {
            var _unitOfWork = new UnitOfWork();
            var query       = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == id);

            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The account was not found."
                      };
            }

            var idParam = new SqlParameter("@ID_NUM", id);
            var result  = RawSqlQuery <WellnessViewModel> .query("GET_HEALTH_CHECK_BY_ID @ID_NUM", idParam); //run stored procedure

            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }


            var wellnessModel = result.Select(x =>
            {
                WellnessViewModel y = new WellnessViewModel();

                DateTime currentTime = DateTime.Now;

                DateTime changeTime = new DateTime(currentTime.Year, currentTime.Month, currentTime.Day, 5, 0, 0);

                // Answer is good until 5am the next day, so changeTime is most recent 5am
                // which might be yesterday.
                if (changeTime > currentTime)
                {
                    TimeSpan day = new TimeSpan(24, 0, 0);
                    changeTime   = new DateTime(changeTime.Ticks - day.Ticks);
                }

                if (x.timestamp >= changeTime)
                {
                    y.answerValid = true;
                    y.userAnswer  = x.userAnswer;
                    y.timestamp   = x.timestamp;
                    return(y);
                }

                y.answerValid = false;
                y.userAnswer  = x.userAnswer;
                y.timestamp   = x.timestamp;

                return(y);
            });


            return(wellnessModel);
        }
        //saves message that was sent in real time in the controller.
        public bool SendMessage(SendTextViewModel textInfo, String user_id)
        {
            var _unitOfWork = new UnitOfWork();
            var query       = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == user_id);

            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The account was not found."
                      };
            }

            var idParam        = new SqlParameter("@_id", textInfo.id);
            var roomIdParam    = new SqlParameter("@room_id", textInfo.room_id);
            var textParam      = new SqlParameter("@text", textInfo.text);
            var createdAtParam = new SqlParameter("@createdAt", textInfo.createdAt);
            var userIdParam    = new SqlParameter("@user_id", user_id);
            var imageParam     = new SqlParameter("@image", System.Data.SqlDbType.VarBinary, -1);
            var videoParam     = new SqlParameter("@video", System.Data.SqlDbType.VarBinary, -1);
            var audioParam     = new SqlParameter("@audio", System.Data.SqlDbType.VarBinary, -1);
            var systemParam    = new SqlParameter("@system", textInfo.system);
            var sentParam      = new SqlParameter("@sent", textInfo.sent);
            var receivedParam  = new SqlParameter("@received", textInfo.received);
            var pendingParam   = new SqlParameter("@pending", textInfo.pending);

            imageParam.Value = DBNull.Value;
            videoParam.Value = DBNull.Value;
            audioParam.Value = DBNull.Value;

            if (textInfo.image != null)
            {
                byte[] decodedByteArray = Convert.FromBase64CharArray(textInfo.image.ToCharArray(), 0, textInfo.image.Length);
                imageParam.Value = decodedByteArray;
            }


            var result = RawSqlQuery <SendTextViewModel> .query("INSERT_MESSAGE @_id, @room_id, @text, @createdAt, @user_id, @image, @video, @audio, @system, @sent, @received, @pending",
                                                                idParam, roomIdParam, textParam, createdAtParam, userIdParam, imageParam, videoParam, audioParam, systemParam, sentParam, receivedParam, pendingParam); //run stored procedure

            var UpdateRoomIdParam = new SqlParameter("@room_id", textInfo.room_id);
            var updateRoom        = RawSqlQuery <SendTextViewModel> .query("UPDATE_ROOM  @room_id", UpdateRoomIdParam); //run stored procedure

            bool returnAnswer = true;

            if (result == null)
            {
                returnAnswer = false;
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }

            return(returnAnswer);
        }
        /// <summary>
        /// get advisors for particular student
        /// </summary>
        /// <param name="id">student id</param>
        /// <returns></returns>
        public IEnumerable <AdvisorViewModel> GetAdvisors(string id)
        {
            var query = _unitOfWork.AccountRepository.FirstOrDefault(x => x.gordon_id == id);

            if (query == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The account was not found."
                      };
            }

            var idParam = new SqlParameter("@ID", id);
            // Stored procedure returns row containing advisor1 ID, advisor2 ID, advisor3 ID
            var idResult = RawSqlQuery <ADVISOR_SEPARATE_Result> .query("ADVISOR_SEPARATE @ID", idParam).FirstOrDefault();

            // Create empty advisor list to fill in and return.
            List <AdvisorViewModel> resultList = new List <AdvisorViewModel>();

            // If idResult equal null, it means this user do not have advisor
            if (idResult == null)
            {
                //return empty list
                return(resultList);
            }
            else
            {
                // Add advisors to resultList, then return the list
                if (!string.IsNullOrEmpty(idResult.Advisor1))
                {
                    resultList.Add(new AdvisorViewModel(
                                       _accountService.Get(idResult.Advisor1).FirstName,
                                       _accountService.Get(idResult.Advisor1).LastName,
                                       _accountService.Get(idResult.Advisor1).ADUserName));
                }
                if (!string.IsNullOrEmpty(idResult.Advisor2))
                {
                    resultList.Add(new AdvisorViewModel(
                                       _accountService.Get(idResult.Advisor2).FirstName,
                                       _accountService.Get(idResult.Advisor2).LastName,
                                       _accountService.Get(idResult.Advisor2).ADUserName));
                }
                if (!string.IsNullOrEmpty(idResult.Advisor3))
                {
                    resultList.Add(new AdvisorViewModel(
                                       _accountService.Get(idResult.Advisor3).FirstName,
                                       _accountService.Get(idResult.Advisor3).LastName,
                                       _accountService.Get(idResult.Advisor3).ADUserName));
                }
            }
            //Set a list to return not null object in array
            return(resultList);
        }
        /// <summary>
        /// Fetch the ride items a user is part of
        /// </summary>
        /// <param name="gordon_id">The ride id</param>
        /// <returns> ride items if found, null if not found</returns>
        public IEnumerable <UPCOMING_RIDES_BY_STUDENT_ID_Result> GetUpcomingForUser(string gordon_id)
        {
            var idParam = new SqlParameter("@STUDENT_ID", gordon_id);
            var result  = RawSqlQuery <UPCOMING_RIDES_BY_STUDENT_ID_Result> .query("UPCOMING_RIDES_BY_STUDENT_ID @STUDENT_ID", idParam); //run stored procedure

            if (result == null)
            {
                return(null);
            }

            return(result);
        }
        /// <summary>
        /// Service method that gets the current session we are in.
        /// </summary>
        /// <returns>SessionViewModel of the current session. If no session is found for our current date, returns null.</returns>
        public static SessionViewModel GetCurrentSession()
        {
            var tempUnitOfWork = new UnitOfWork();
            var sessionService = new SessionService(tempUnitOfWork);

            var query = RawSqlQuery <String> .query("CURRENT_SESSION");

            var currentSessionCode = query.Select(x => x).FirstOrDefault();

            SessionViewModel result = sessionService.Get(currentSessionCode);

            return(result);;
        }
        /// <summary>
        /// Calls a stored procedure that returns a row in the staff whitelist which has the given user id,
        /// if it is in the whitelist
        /// </summary>
        /// <param name="userID"> The id of the person using the page </param>
        /// <returns> Whether or not the user is on the staff whitelist </returns>
        public bool CheckIfHousingAdmin(string userID)
        {
            IEnumerable <HousingAdminViewModel> idResult = null;

            SqlParameter idParam = new SqlParameter("@USER_ID", userID);

            idResult = RawSqlQuery <HousingAdminViewModel> .query("GET_AA_ADMIN @USER_ID", idParam);

            if (idResult == null || !idResult.Any())
            {
                return(false);
            }

            return(true);
        }
        public static IEnumerable <Alumni> GetAllAlumni()
        {
            IEnumerable <Alumni> result = null;

            try
            {
                // Attempt to query the DB
                result = RawSqlQuery <Alumni> .query(SQLQuery.ALL_ALUMNI_REQUEST);
            }
            catch
            {
                //
            }
            // Filter out results with null or empty active directory names
            return(result);
        }
        /// <summary>
        /// Calls a stored procedure that gets all names of apartment halls
        /// </summary>
        /// <returns> AN array of hall names </returns>
        public AA_ApartmentHalls[] GetAllApartmentHalls()
        {
            IEnumerable <AA_ApartmentHalls> hallsResult = null;

            hallsResult = RawSqlQuery <AA_ApartmentHalls> .query("GET_AA_APARTMENT_HALLS");

            if (hallsResult == null || !hallsResult.Any())
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The apartment halls could not be found."
                      };
            }

            return(hallsResult.ToArray());
        }
        /// <summary>
        /// Get a list of emails for group admin in the activity during a specified session.
        /// </summary>
        /// <param name="activity_code"></param>
        /// <param name="session_code"></param>
        /// <returns>A collection of the group admin emails</returns>
        public IEnumerable <EmailViewModel> GetEmailsForGroupAdmin(string activity_code, string session_code)
        {
            var idParam   = new SqlParameter("@ACT_CDE", activity_code);
            var sessParam = new SqlParameter("@SESS_CDE", session_code);
            var result    = RawSqlQuery <EmailViewModel> .query("GRP_ADMIN_EMAILS_PER_ACT_CDE @ACT_CDE, @SESS_CDE", idParam, sessParam);

            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The Activity was not found."
                      };
            }

            return(result);
        }
        public static IEnumerable <FacStaff> GetAllFacultyStaff()
        {
            IEnumerable <FacStaff> result = null;

            try
            {
                // Attempt to query the DB
                result = RawSqlQuery <FacStaff> .query(SQLQuery.ALL_FACULTY_STAFF_REQUEST);
            }
            catch
            {
                //
            }
            // Filter out results with null or empty active directory names
            return(result);
        }
        public static IEnumerable <BasicInfoViewModel> GetAllBasicInfoExcludeAlumni()
        {
            IEnumerable <BasicInfoViewModel> result = null;

            try
            {
                // Attempt to query the DB
                result = RawSqlQuery <BasicInfoViewModel> .query(SQLQuery.ALL_BASIC_INFO_NOT_ALUM);
            }
            catch
            {
                //
            }
            // Filter out results with null or empty active directory names
            return(result);
        }
        /// <summary>
        /// gets the question for the wellness check from the back end
        /// </summary>
        /// <returns>A WellnessQuestionViewModel including the text of the question and the disclaimers for positive and negative answers.</returns>

        public WellnessQuestionViewModel GetQuestion()
        {
            var result = RawSqlQuery <WellnessQuestionViewModel> .query("GET_HEALTH_CHECK_QUESTION"); //run stored procedure

            if (result == null)
            {
                throw new ResourceNotFoundException()
                      {
                          ExceptionMessage = "The data was not found."
                      };
            }

            var wellnessQuestionModel = result.SingleOrDefault();

            return(wellnessQuestionModel);
        }