예제 #1
0
        public static WithdrawalsDTO GetById(int id)
        {
            WithdrawalsDTO withdrawalsDTO = new WithdrawalsDTO();
            db             DB             = new db();
            var            withdrawal     = DB.Withdrawing.FirstOrDefault(w => w.Id == id);

            withdrawalsDTO = WithdrawalsConvert.DALtoDTO(withdrawal);
            return(withdrawalsDTO);
        }
예제 #2
0
        public static List <WithdrawalsDTO> GetAll()
        {
            List <WithdrawalsDTO> withdrawalsDTOs = new List <WithdrawalsDTO>();
            db DB = new db();
            List <withdrawing> withdrawals = DB.Withdrawing.ToList();

            foreach (withdrawing withdrawal in withdrawals)
            {
                withdrawalsDTOs.Add(WithdrawalsConvert.DALtoDTO(withdrawal));
            }
            return(withdrawalsDTOs);
        }
예제 #3
0
        public static List <WithdrawalsDTO> GetByUser(int userId)
        {
            List <WithdrawalsDTO> withdrawalsDTOs = new List <WithdrawalsDTO>();
            db DB = new db();
            List <withdrawing> withdrawals = DB.Withdrawing.Where(w => w.UserId == userId).ToList();

            foreach (withdrawing withdrawal in withdrawals)
            {
                WithdrawalsDTO withdrawalDTO = WithdrawalsConvert.DALtoDTO(withdrawal);
                withdrawalDTO.Fund = DB.Funds.FirstOrDefault(f => f.FundId == withdrawal.FundId).fund_name;
                withdrawalsDTOs.Add(withdrawalDTO);
            }
            return(withdrawalsDTOs);
        }
예제 #4
0
        public static void Add(WithdrawalsDTO withdrawalDTO)
        {
            withdrawing withdrawal = WithdrawalsConvert.DTOtoDAL(withdrawalDTO);
            db          DB         = new db();

            DB.Withdrawing.Add(withdrawal);
            DB.SaveChanges();
            if (withdrawalDTO.Status == "performed")
            {
                FundBL.Subtract_Balance(withdrawalDTO.Amount, withdrawalDTO.FundId);
                User_in_fund user = DB.UserInFunds.FirstOrDefault(u => u.UserId == withdrawal.UserId && u.FundId == withdrawal.FundId);
                user.balance -= withdrawal.Amount;
            }
            DB.SaveChanges();
        }
예제 #5
0
        public static List <WithdrawalsDTO> GetByFund(string FundId)
        {
            List <WithdrawalsDTO> withdrawalsDTOs = new List <WithdrawalsDTO>();
            db DB = new db();
            List <withdrawing> withdrawals = DB.Withdrawing.Where(w => w.FundId == FundId).ToList();

            foreach (withdrawing withdrawal in withdrawals)
            {
                WithdrawalsDTO withdrawalDTO = WithdrawalsConvert.DALtoDTO(withdrawal);

                //  User_in_fund  User= DB.User_in_fund.FirstOrDefault(u => u.userID == withdrawal.UserId);
                // withdrawalDTO.User = UserBL.Get_user_byFund(FundId, withdrawal.UserId);
                withdrawalsDTOs.Add(withdrawalDTO);
            }
            return(withdrawalsDTOs);
        }