public static void MarkDepositFinished(List <int> ids) { try { using (DepositContext db = new DepositContext()) { var deposits = db.Deposits?.Where(p => ids.Contains(p.Id)).ToList(); foreach (var deposit in deposits) { deposit.Status = StatusDeposit.Finished; } db.SaveChanges(); } } catch (Exception e) { } }
public static List <Deposit> GetActiveDepost() { List <Deposit> deposits = new List <Deposit>(); try { using (DepositContext db = new DepositContext()) { deposits = db.Deposits?.Where(p => p.Status == StatusDeposit.Active).ToList(); } } catch (Exception e) { deposits = new List <Deposit>(); } return(deposits); }
public static List <Deposit> GetDepostByUserId(int userId) { List <Deposit> deposits = new List <Deposit>(); try { using (DepositContext db = new DepositContext()) { deposits = db.Deposits?.Where(p => p.UserId == userId).ToList(); } } catch (Exception e) { deposits = new List <Deposit>(); } return(deposits); }
public static bool AddNewDeposit(Deposit deposit) { var success = false; try { using (DepositContext db = new DepositContext()) { db.Deposits.Add(deposit); db.SaveChanges(); success = true; } } catch (Exception e) { success = false; } return(success); }
public DepositRepository(DepositContext depositContext) { _depositContext = depositContext; }