internal async Task <bool> LinkRenterAndLeaser(int leaserId, int renterId) { var leaser = await this.leaserRepository .GetLeaserByIdAsync(leaserId); if (leaser == null) { return(false); } var renter = await this.renterRepository .GetRenterByIdAsync(renterId); if (renter == null) { return(false); } var transaction = new RenterLeaserTransaction { LeaserId = leaserId, RenterId = renterId, CreatedDate = DateTime.Now, LastModifiedDate = DateTime.Now, TransactionStatus = RenterLeaserTransactionStatus.Pending, }; this.transactionRepository.AddTransaction(transaction); return(await this.transactionRepository.SaveChangesAsync()); }
private async Task ModifyRemainingTransactions(RenterLeaserTransaction currentTransaction) { var renterId = currentTransaction.RenterId; var leaserId = currentTransaction.LeaserId; await this.renterService.MarkAsFound(renterId, false); await this.leaserService.MarkAsLeased(leaserId, false); var remainingTransactions = this.transactionRepository .Transactions .Where(x => x.ID != currentTransaction.ID && x.TransactionStatus == RenterLeaserTransactionStatus.Pending && ( (x.LeaserId == leaserId) || (x.RenterId == renterId) )).ToList(); foreach (var remainingTransaction in remainingTransactions) { remainingTransaction.TransactionStatus = RenterLeaserTransactionStatus.NoDeal; remainingTransaction.LastModifiedDate = DateTime.Now; } }
public void ModifyTransaction(RenterLeaserTransaction renterLeaserTransaction) { this.roomForRentDbContext. Transactions.Update(renterLeaserTransaction); }
public void AddTransaction(RenterLeaserTransaction renterLeaserTransaction) { this.roomForRentDbContext.Transactions.Add(renterLeaserTransaction); }