public static DepositDetails GetById(int id) { DepositDetails depositDetails = new DepositDetails(); try { DB db = new SuperGmachEntities(); Deposit deposit = db.Deposits.FirstOrDefault(d => d.DepositId == id); depositDetails = DepositConvert.DALtoDepositDetails(deposit); } catch (Exception e) { throw e; } return(depositDetails); }
public static List <DepositDetails> GetList() { List <DepositDetails> deposits = new List <DepositDetails>(); try { DB db = new SuperGmachEntities(); foreach (var deposit in db.Deposits) { deposits.Add(DepositConvert.DALtoDepositDetails(deposit)); } } catch (Exception e) { throw e; } return(deposits); }
public static List <DepositDetails> GetByFundId(string FundId) { List <DepositDetails> deposits = new List <DepositDetails>(); try { DB db = new SuperGmachEntities(); List <Deposit> deposits_DAL = db.Deposits.Where(d => d.FundId == FundId).ToList(); foreach (var deposit in deposits_DAL) { deposits.Add(DepositConvert.DALtoDepositDetails(deposit)); } } catch (Exception e) { throw e; } return(deposits); }
public static void AddDeposit(DepositDTO deposit) { DB db = new SuperGmachEntities(); try { Deposit deposit_DAL = new Deposit(); deposit_DAL = DepositConvert.DTOtoDAL(deposit); // System.Console.WriteLine(deposit+" DAL/n "+deposit_DAL); db.Deposits.Add(deposit_DAL); User user = db.Users.FirstOrDefault(); db.SaveChanges(); user.Scoring = (int)((int)user.Scoring + deposit.Amount * 0.5); User_in_fund user_In_Fund = db.UserInFunds.FirstOrDefault(u => u.UserId == deposit.UserId && u.FundId == deposit.FundId); user_In_Fund.balance += deposit.Amount; FundBL.AddBalance((int)deposit.Amount, deposit.FundId); db.SaveChanges(); } catch (Exception e) { throw e; } }