예제 #1
0
        /// <summary>
        /// Retorna uma lista de caronas com a solicitação em aberta deste usuário
        /// </summary>
        /// <param name="userID">ID do usuário a ter suas solicitações de reserva pesquisadas</param>
        /// <returns>Uma lista com todas as caronas reservadas</returns>
        public static List <RidesModel> GetAllRidesFromReservation(Guid userID)
        {
            DBConfigurations database = new DBConfigurations();
            var listRidesRequest      = RidesRequestManager.GetAllRequestedByUser(userID);
            var listRides             = new List <RidesModel>();

            foreach (var rideRequest in listRidesRequest)
            {
                var ride = (from rides in database.Ride where rides.ID == rideRequest.RideID select rides).First();
                listRides.Add(Conversor.RidesToModel(ride));
            }
            return(listRides);
        }
예제 #2
0
        /// <summary>
        /// Realiza consulta para trazer os dados do usuário no banco de dados e armazenar o resultado em uma
        /// variável de seção.
        /// </summary>
        /// <param name="userID">ID do usuário logado (Guid)</param>
        /// <param name="error">Enum de retorno de erros</param>
        /// <returns></returns>
        public static UserModel RetrieveUser(Guid userID, out ErrorEnum error)
        {
            DBConfigurations database = new DBConfigurations();

            error = ErrorEnum.NoErrors;

            try
            {
                var userDTO   = (from user in database.Users where user.ID == userID select user).First();
                var userModel = Conversor.UserDTOToModel(userDTO);

                #region Messages

                var messagesDTO = UserManager.GetMessages(userModel.ID);
                userModel.MessagesFromMe = new List <Messages>();
                userModel.MessagesToMe   = new List <Messages>();

                foreach (var message in messagesDTO)
                {
                    if (message.SenderID == userModel.ID)
                    {
                        userModel.MessagesFromMe.Add(message);
                    }
                    else
                    {
                        userModel.MessagesToMe.Add(message);
                    }
                }
                #endregion

                #region Rides

                userModel.DonorRides    = RidesManager.GetDonorRides(userModel.ID);
                userModel.ReceiverRides = RidesManager.GetReceiverRides(userModel.ID);
                userModel.OpenRequests  = RidesManager.GetRidesRequests(userModel.ID);

                #endregion

                #region BankAccount

                var userBankAccount = UserBankManager.GetUserBankAccount(userDTO.UserBankID);
                userModel.BankAccount.Account = userBankAccount.Account;
                userModel.BankAccount.Agency  = userBankAccount.Agency;
                userModel.BankAccount.BankID  = userBankAccount.BankID;
                userModel.BankAccount.ID      = userBankAccount.ID;

                #endregion

                #region Image

                userModel.FileContentResult = ImagesManager.RetrieveImage(userModel.ID);

                #endregion

                #region Friends Requests

                userModel.FriendsRequests = FriendshipManager.GetFriendsRequests(userModel.ID);

                #endregion

                #region ListNotifications

                userModel.ListNotifications = NotificationsManager.GetUserNotifications(userModel.ID);
                userModel.RidesRequests     = RidesRequestManager.GetAllRequestsByDriver(userModel.ID);

                #endregion

                return(userModel);
            }
            catch (Exception)
            {
                error = ErrorEnum.ExceptionError;
                return(null);
            }
        }