public UnitOfWork(DBMarket context) { Products = new ProductRepository(context); Categories = new CategoryRepository(context); PaymentTypes = new PaymentTypeRepository(context); Tags = new TagRepository(context); }
public List <TransactionModel> GetTransactions(Guid accountId) { var returnList = new List <Models.TransactionModel>(); if (OptionsBuilder == null) { throw new Exception("Service is not started"); } ITransactionRepository repo = new TransactionRepository(); var accountTranactions = repo.GetTransactions(accountId, OptionsBuilder); ICategoryRepository catRepo = new CategoryRepository(); IPaymentTypeRepository pTypeRepo = new PaymentTypeRepository(); for (int i = 0; i < accountTranactions.Count; i++) { var returnValue = new TransactionModel(); returnValue.IsDeposit = accountTranactions[i].IsDeposit; returnValue.CategoryName = catRepo.GetCategory(accountTranactions[i].CategoryId, OptionsBuilder).CategoryName; returnValue.CategoryId = accountTranactions[i].CategoryId; returnValue.PaymentTypeName = pTypeRepo.GetPaymentType(accountTranactions[i].PaymentTypeId, OptionsBuilder).Name; returnValue.PaymentTypeId = accountTranactions[i].PaymentTypeId; returnValue.AccountId = accountTranactions[i].AccountId; returnValue.Amount = accountTranactions[i].Amount; returnValue.Description = accountTranactions[i].Description; returnValue.Id = accountTranactions[i].Id; returnValue.TransactionDate = accountTranactions[i].TransactionDate; returnList.Add(returnValue); } return(returnList); }
public PaymentType GetProduct(int paymentTypeId) { var repo = new PaymentTypeRepository(); var paymentType = repo.GetPaymentType(paymentTypeId); return(paymentType); }
public HomeController() { _restaurantDBEntities = new RestaurantDBEntities(); _customerReposistory = new CustomerRepository(); _itemRepository = new ItemRepository(); _paymentTypeRepository = new PaymentTypeRepository(); }
public IEnumerable <PaymentType> GetPaymentTypes() { var repo = new PaymentTypeRepository(); var paymentTypes = repo.GetAllPaymentTypes(); return(paymentTypes); }
public static bool deletePaymentType(int id) { if (TransactionRepository.getPaymentHeader(id) != null) { return(false); } PaymentTypeRepository.delete(id); return(true); }
public static bool DeletePaymentType(int id) { if (PaymentTypeRepository.GetPaymentType(id) != null) { PaymentTypeRepository.DeletePaymentType(id); return(true); } return(false); }
public static bool UpdatePaymentType(int id, string type) { if (PaymentTypeRepository.GetPaymentType(id) != null) { PaymentTypeRepository.UpdatePaymentType(id, type); return(true); } return(false); }
public PaymentTypeController( PaymentTypeRepository repository, IMapper mapper, PaymentRepository paymentRepository) { _mapper = mapper; _repository = repository; _paymentRepository = paymentRepository; }
// GET: Home public ActionResult Index() { CustomerRepository objCustomerRepository = new CustomerRepository(); ItemRepository objItemRepository = new ItemRepository(); PaymentTypeRepository objPaymentTypeRepository = new PaymentTypeRepository(); var objMultipleModels = new Tuple <IEnumerable <SelectListItem>, IEnumerable <SelectListItem>, IEnumerable <SelectListItem> > (objCustomerRepository.GetAllCustomers(), objItemRepository.GetAllItems(), objPaymentTypeRepository.GetAllPaymentType()); return(View(objMultipleModels)); }
public void CloseDown() { paymentRepository = null; DeleteTransactionTypeRows(); paymentTypeRepository = null; fundTypeRepository = null; budgetTypeRepository = null; }
public void Delete(UpdatePaymentTypeCommand updatedPaymentTypeCommand, int id) { var repo = new PaymentTypeRepository(); var updatedPaymentType = new PaymentType { Name = updatedPaymentTypeCommand.Name, }; repo.DeletePaymentType(updatedPaymentType, id); }
public static Boolean updatePaymentType(int id, string type) { if (PaymentTypeRepository.updatePaymentType(id, type)) { return(true); } else { return(false); } }
public PaymentController( PaymentRepository repository, PaymentTypeRepository paymentTypeRepository, IMapper mapper, DropboxService dropboxService) { this._repository = repository; _paymentTypeRepository = paymentTypeRepository; _mapper = mapper; _dropboxService = dropboxService; }
public static List <string> getPaymentData() { List <PaymentType> vPayment = PaymentTypeRepository.read(); List <string> payment = new List <string>(); foreach (PaymentType pt in vPayment) { payment.Add(pt.PaymentTypeName); } return(payment); }
// GET: Home public ActionResult Index() { CustomerRepository customerRepo = new CustomerRepository(); ItemRepository itemRepo = new ItemRepository(); PaymentTypeRepository paymentTypeRepo = new PaymentTypeRepository(); var objMultipleObjects = new Tuple <IEnumerable <SelectListItem>, IEnumerable <SelectListItem>, IEnumerable <SelectListItem> > (customerRepo.GetAllCustomers(), itemRepo.GetAllItems(), paymentTypeRepo.GetAllPaymentTypes()); return(View(objMultipleObjects)); }
public TripControllerTests(ControllerFixture fixture) { Context = fixture.Context; TripRepository = fixture.TripRepository; CalendarRepository = fixture.CalendarRepository; CompanyRepository = fixture.CompanyRepository; NeighborhoodRepository = fixture.NeighborhoodRepository; PatternAreaRepository = fixture.PatternAreaRepository; PaymentTypeRepository = fixture.PaymentTypeRepository; VehicleRepository = fixture.VehicleRepository; VehicleTypeRepository = fixture.VehicleTypeRepository; }
public UnitOfWork(ApplicationDbContext applicationDbContext) { _context = applicationDbContext; Operations = new OperationRepository(applicationDbContext); OperationTypes = new OperationTypeRepository(applicationDbContext); Scores = new ScoreRepository(applicationDbContext); PaymentTypes = new PaymentTypeRepository(applicationDbContext); Projects = new ProjectRepository(applicationDbContext); Users = new UserRepository(applicationDbContext); CounterParties = new CounterPartyRepository(applicationDbContext); Transactions = new TransactionRepository(applicationDbContext); }
// GET: Homie public ActionResult Index() { CustomerRepository _customerRepo = new CustomerRepository(); FoodRepository _foodRepo = new FoodRepository(); PaymentTypeRepository _paymentRepo = new PaymentTypeRepository(); var objMultiple = new Tuple <IEnumerable <SelectListItem>, IEnumerable <SelectListItem>, IEnumerable <SelectListItem> > (_customerRepo.GetAllCustomer(), _foodRepo.GetAllFood(), _paymentRepo.GetAllPaymentType()); return(View(objMultiple)); }
public void Setup(IRepository <Income> incomeRepository, PaymentTypeRepository paymentTypeRepository, BudgetTypeRepository budgetTypeRepository, FundTypeRepository fundTypeRepository) { this.incomeRepository = incomeRepository; this.paymentTypeRepository = paymentTypeRepository; this.budgetTypeRepository = budgetTypeRepository; this.fundTypeRepository = fundTypeRepository; InitialiseParameters(); CreateTransactionTypeRows(); }
public ControllerFixture() { Mapper.Initialize(cfg => { cfg.AddProfile <DeploymentProfile>(); cfg.AddProfile <TripProfile>(); cfg.AddProfile <CollisionProfile>(); cfg.AddProfile <ComplaintProfile>(); }); DbContextOptions <ScootertownDbContext> options; var builder = new DbContextOptionsBuilder <ScootertownDbContext>(); builder.UseInMemoryDatabase("API"); options = builder.Options; var context = new ScootertownDbContext(options, new VehicleStoreOptions()); var cache = new Mock <IMemoryCache>(); var entry = new Mock <ICacheEntry>(); int expectedKey = 1; object expectedValue = expectedKey; cache .Setup(x => x.TryGetValue(It.IsAny <object>(), out expectedValue)) .Returns(true); cache .Setup(m => m.CreateEntry(It.IsAny <object>())) .Returns(entry.Object); DeploymentRepository = new DeploymentRepository(context); TripRepository = new TripRepository(context); CollisionRepository = new CollisionRepository(context); ComplaintRepository = new ComplaintRepository(context); CalendarRepository = new CalendarRepository(context, cache.Object); CompanyRepository = new CompanyRepository(context, cache.Object); NeighborhoodRepository = new NeighborhoodRepository(context, cache.Object); PatternAreaRepository = new PatternAreaRepository(context, cache.Object); PaymentTypeRepository = new PaymentTypeRepository(context, cache.Object); PlacementReasonRepository = new PlacementReasonRepository(context, cache.Object); RemovalReasonRepository = new RemovalReasonRepository(context, cache.Object); StatusRepository = new StatusRepository(context, cache.Object); VehicleRepository = new VehicleRepository(context, cache.Object); VehicleTypeRepository = new VehicleTypeRepository(context, cache.Object); Context = context; }
//Using dependency injection i pulled my Restaurantmodles datatdabe within the contructor /*In index controller and a corresponding index view to return too. * Now our first issue with using this multiple view model format is that * I need to pass multiple view models to a single view. To solve this I used the tuple solution.*/ public ActionResult Index() { CustomerRepository customerRepository = new CustomerRepository(); ItemRepository itemRepository = new ItemRepository(); PaymentTypeRepository paymentTypeRepository = new PaymentTypeRepository(); var MultipleModles = new Tuple <IEnumerable <SelectListItem>, IEnumerable <SelectListItem>, IEnumerable <SelectListItem> > (customerRepository.GetAllCustomer(), itemRepository.GetAllItems(), paymentTypeRepository.GetAllPaymentType()); //Using a tuple i inputted the databse repositories into the item property of the tuple and implimented the get... method to pull the data. return(View(MultipleModles)); }
public UnitOfWork(BusTicketContext context) { _context = context; Vendor = new VendorRepository(_context); BusDetail = new BusDetailRepository(_context); Route = new RouteRepository(_context); BusCategory = new BusCategoryRepository(_context); Brand = new BrandRepository(_context); PaymentType = new PaymentTypeRepository(_context); PromoOffer = new PromoOfferRepository(_context); BusReservation = new BusReservationRepository(_context); SeatLayout = new SeatLayoutRepository(_context); TicketReservation = new TicketReservationRepository(_context); VendorPayment = new VendorPaymentRepository(_context); Payment = new PaymentRepository(_context); }
public async Task GetPaymentTypesAsync_Returns_GetPaymentTypeDtos() { //Arrange _fixture.MockPaymentTypeService.Setup(x => x.GetPaymentTypesAsync()) .ReturnsAsync(_fixture.PaymentTypes); var repository = new PaymentTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockPaymentTypeService.Object); //Act var result = await repository.GetPaymentTypesAsync(); //Assert var paymentTypes = result.Should().BeAssignableTo <IEnumerable <GetPaymentTypeDto> >().Subject; paymentTypes.Should().HaveCount(2); }
public static void checkOut(int userId, string paymentType) { List <vCart> cartData = CartRepository.read(userId); int paymentId = PaymentTypeRepository.findPayment(paymentType).PaymentTypeId; int transactionId = TransactionRepository.insertHeaderTransaction (HeaderTransactionFactory.newHeader(userId, paymentId)).TransactionID; foreach (vCart item in cartData) { int productId = item.Product_Id; int qty = item.Quantity; TransactionRepository.insertDetailTransaction(DetailTransactionFactory.createDetail(transactionId, productId, qty)); CartRepository.delete(userId, productId); int currentStock = ProductRepository.findProductDetail(productId).Stock - qty; ProductRepository.updateStock(productId, currentStock); } }
public void Setup(IRepository <Payment> paymentRepository, PaymentTypeRepository paymentTypeRepository, BudgetTypeRepository budgetTypeRepository, FundTypeRepository fundTypeRepository, SpendTypeRepository spendTypeRepository ) { this.paymentRepository = paymentRepository; this.paymentTypeRepository = paymentTypeRepository; this.fundTypeRepository = fundTypeRepository; this.budgetTypeRepository = budgetTypeRepository; this.spendTypeRepository = spendTypeRepository; InitialiseParameters(); CreateTransactionTypeRows(); }
public async Task CreatePaymentTypeAsync_Returns_New_GetPaymentTypeDto() { //Arrange _fixture.MockPaymentTypeService.Setup(x => x.AddPaymentTypeAsync(It.IsAny <PaymentType>())) .ReturnsAsync(_fixture.CreatedNewPaymentType); var repository = new PaymentTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockPaymentTypeService.Object); //Act var result = await repository.CreatePaymentTypeAsync(_fixture.CreatePaymentTypeDto); //Assert result.Should().BeOfType(typeof(GetPaymentTypeDto)); result.Id.Should().Be(3); result.Name.Should().Be(_fixture.CreatePaymentTypeDto.Name); result.CreditPeriod.Should().Be(_fixture.CreatePaymentTypeDto.CreditPeriod); }
public async Task CreatePaymentTypeAsync_Throws_ConflictException() { //Arrange _fixture.MockPaymentTypeService.Setup(x => x.GetPaymentTypeAsync(It.IsAny <Expression <Func <PaymentType, bool> > >())) .Returns <Expression <Func <PaymentType, bool> > >(expression => Task.FromResult(_fixture.PaymentTypes.AsQueryable().FirstOrDefault(expression))); var repository = new PaymentTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockPaymentTypeService.Object); //Act var exception = await Assert.ThrowsAsync <RestException>(() => repository.CreatePaymentTypeAsync(new CreatePaymentTypeDto { Name = "Credit", CreditPeriod = 10 })); //Assert exception.ErrorCode.Should().Be(HttpStatusCode.Conflict); exception.ErrorMessage.Should().Be("Payment type Credit is already available."); exception.ErrorType.Should().Be(HttpStatusCode.Conflict.ToString()); }
public async Task DeletePaymentTypeAsync_Returns_NoResult() { //Arrange var id = 2; _fixture.MockPaymentTypeService.Setup(x => x.GetPaymentTypeAsync(It.IsAny <Expression <Func <PaymentType, bool> > >())) .Returns <Expression <Func <PaymentType, bool> > >(expression => Task.FromResult(_fixture.PaymentTypes.AsQueryable().FirstOrDefault(expression))); _fixture.MockPaymentTypeService.Setup(x => x.DeletePaymentTypeAsync(It.IsAny <PaymentType>())); var repository = new PaymentTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockPaymentTypeService.Object); //Act await repository.DeletePaymentTypeAsync(id); // Assert _fixture.MockPaymentTypeService.Verify(x => x.DeletePaymentTypeAsync(It.IsAny <PaymentType>()), Times.Once); }
public async Task GetPaymentTypeAsync_Throws_NotFoundException() { //Arrange var id = 201; _fixture.MockPaymentTypeService.Setup(x => x.GetPaymentTypeAsync(It.IsAny <Expression <Func <PaymentType, bool> > >())) .Returns <Expression <Func <PaymentType, bool> > >(expression => Task.FromResult(_fixture.PaymentTypes.AsQueryable().FirstOrDefault(expression))); var repository = new PaymentTypeRepository(AutoMapperSingleton.Mapper, _fixture.MockPaymentTypeService.Object); //Act var exception = await Assert.ThrowsAsync <RestException>(() => repository.GetPaymentTypeAsync(id)); //Assert exception.ErrorCode.Should().Be(HttpStatusCode.NotFound); exception.ErrorMessage.Should().Be("Payment type not found."); exception.ErrorType.Should().Be(HttpStatusCode.NotFound.ToString()); }
public void Init() { ctx = EFContext.CreateContext(); repo = new PaymentTypeRepository(ctx); }