public HttpResponseMessage DeletePayment(int id) { Payment Payment = PaymentRepository.Get(t => t.PaymentId == id); if (Payment == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } PaymentRepository.Delete(Payment); try { unitOfWork.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex)); } return(Request.CreateResponse(HttpStatusCode.OK, Payment)); }
public IEnumerable <Payment> GetOverall_Old() { CostCenter working; List <Payment> payments; // 1. Get working costcenter. working = AuthManager.GetWorkingCostCenter(); // 2. Get payment data. using (PaymentRepository paymentRepo = new PaymentRepository()) { payments = paymentRepo.Get() .Where( p => p.CostCenterID.StartsWith(working.CostCenterTrim) && p.Status == RecordStatus.Active ) .OrderBy(p => p.PaymentDate) .ToList(); } return(payments); }
public async void Get_NothingMatched() { // Arrange var paymentRepository = new PaymentRepository(ambientDbContextLocator); var accountRepository = new AccountRepository(ambientDbContextLocator); var testAccount = new AccountEntity { Name = "testAccount" }; using (var dbContextScope = dbContextScopeFactory.Create()) { accountRepository.Add(testAccount); await dbContextScope.SaveChangesAsync(); } PaymentEntity result; // Act using (var dbContextScope = dbContextScopeFactory.Create()) { paymentRepository.Add(new PaymentEntity { ChargedAccount = testAccount }); paymentRepository.Add(new PaymentEntity { ChargedAccount = testAccount }); paymentRepository.Add(new PaymentEntity { ChargedAccount = testAccount }); await dbContextScope.SaveChangesAsync(); result = await paymentRepository.Get(x => x.Note == "text"); } // Assert Assert.Null(result); }
public async void Get_MatchedDataReturned() { // Arrange var factory = new DbFactory(); var unitOfWork = new UnitOfWork(factory); var repository = new PaymentRepository(factory); var filterText = "Text"; var testEntry = new PaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" }, Note = filterText }; repository.Add(testEntry); repository.Add(new PaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); repository.Add(new PaymentEntity { ChargedAccount = new AccountEntity { Name = "testAccount" } }); await unitOfWork.Commit(); // Act var result = await repository.Get(x => x.Note == filterText); // Assert Assert.NotNull(result); Assert.Equal(testEntry.Id, result.Id); }
public IHttpActionResult GetPaymentMethod(int paymentId) { return(Ok(paymentRepository.Get(paymentId))); }
public Payment Get(int id) { return(PaymentRepository.Get(t => t.PaymentId == id)); }
public async Task <List <ViewPayment> > GetAllAsync() { return(await repo.Get().Select(x => new ViewPayment(x)).ToListAsync()); }