public dynamic GetAllPreviousSalesPaymentList(int id) { SaleRepository repo = new SaleRepository(); dynamic getSalesPaymentlist = repo.GetAllPreviousSalesPaymentList(id); return(getSalesPaymentlist); }
public void Test_SaleController_GetById(int id) { var fakeContext = new FakeContext("SaleController_GetById"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var controller = new SaleController(service); var response = controller.GetById(id); var okResult = response as OkObjectResult; var resultValue = okResult.Value; Assert.NotNull(okResult); Assert.Equal(200, okResult.StatusCode); Assert.Equal(repository.GetById(id), okResult.Value); Assert.IsType <Sale>(resultValue); } }
public dynamic GetAllSalesPaymentList() { SaleRepository repo = new SaleRepository(); dynamic getSalesPaymentlist = repo.GetAllSalesPaymentList(); return(getSalesPaymentlist); }
public UnitOfWork(PharmacyContext context) { _context = context; Pharmacy = new PharmacyRepository(_context); Order = new OrderRepository(_context); Sale = new SaleRepository(_context); }
public async void Test_Return_Message_When_NotFound_SaleController_Delete() { var fakeContext = new FakeContext("Test_Return_Message_When_NotFound_SaleController_Delete"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var controller = new SaleController(service); var response = await controller.Delete(10); var okResult = response as NotFoundObjectResult; Assert.NotNull(okResult); Assert.Equal(404, okResult.StatusCode); } }
public dynamic GetInvoice() { SaleRepository repo = new SaleRepository(); var invoiceID = repo.GetInvoice(); return(invoiceID); }
public SaleController GetController() { ISaleRepository saleRepository = new SaleRepository(); ISaleRemarkRepository saleRemarkRepository = new SaleRemarkRepository(); IAccountRepository accountRepository = new AccountRepository(); IOrgInfoRepository orgInfoRepository = new OrgInfoRepository(); IRoleUserRepository roleUserRepository = new RoleUserRepository(); ISectionRepository sectionRepository = new SectionRepository(); IStoreRepository storeRepository = new StoreRepository(); IAccountService accountService = new AccountService(accountRepository, orgInfoRepository, roleUserRepository, sectionRepository, storeRepository); ISaleService saleService = new SaleService(saleRepository, saleRemarkRepository, accountService); //IBrandRepository brandRepository = new BrandRepository(); IShippingSaleRepository shippingSaleRepository = new ShippingSaleRepository(); IOrderRepository orderRepository = new OrderRepository(); //IOrderRemarkRepository orderRemarkRepository = new OrderRemarkRepository(); //IOrderItemRepository orderItemRepository = new OrderItemRepository(); //ISaleDetailRepository saleDetailRepository = new SaleDetailRepository(); ISaleRMARepository saleRmaRepository = new SaleRMARepository(); // IOrderService orderService = new OrderService(orderRepository, orderRemarkRepository, orderItemRepository, brandRepository, accountService, saleDetailRepository, saleRmaRepository); IShippingSaleService shippingSaleService = new ShippingSaleService(shippingSaleRepository, orderRepository, saleRmaRepository, accountService); ISaleRepository saleOrderRepository = new SaleRepository(); ISalesOrderService saleOrderService = new SalesOrderService(saleOrderRepository); _controller = new SaleController(saleService, shippingSaleService, saleOrderService); _controller.Request = new HttpRequestMessage(); _controller.Request.SetConfiguration(new HttpConfiguration()); return(_controller); }
public async void Test_Delete_Sale_Service() { var fakeContext = new FakeContext("Delete_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var response = await service.Delete(1); Assert.Equal("{ Message = Venda cancelada com sucesso. }", response.ToString()); } }
public void Test_GetById_Sale_Service(int id) { var fakeContext = new FakeContext("GetById_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var test = service.GetById(id); Assert.Equal(id, test.Id); Assert.NotNull(test); Assert.IsType <Sale>(test); Assert.Equal(repository.GetById(id).Quantity, service.GetById(id).Quantity); } }
public async void Test_Return_Message_When_Wrong_Id_Update_Sale_Service() { var fakeContext = new FakeContext("Return_Message_When_Wrong_Id_Update_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var currentSale = service.GetById(1); var response = await service.Update(2, currentSale); Assert.Equal("{ Message = Não é possível alterar o produto vendido. " + "É preciso cancelar a venda e criar uma nova venda. }", response.ToString()); } }
public async void Test_Return_Message_When_Wrong_Id_Delete_Sale_Service() { var fakeContext = new FakeContext("Return_Message_When_Wrong_Id_Delete_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var response = await service.Delete(6); Assert.Null(response); } }
public void Test_GetAll_Sale_Service() { var fakeContext = new FakeContext("GetAll_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var test = service.GetAll(); var countSales = context.Sales.Count(); Assert.Equal(countSales, test.Count()); Assert.Equal(context.Sales.ToList(), test); Assert.IsType <SaleRepository>(repository); Assert.IsType <ProductRepository>(productRepository); Assert.IsType <Mock <IUpdateProduct> >(updateMock); Assert.IsType <Mock <IMessageHandler> >(messageMock); } }
public async void Test_Return_Message_When_Quantity_Larger_Than_Stock_Create_Sale_Service() { var fakeContext = new FakeContext("Return_Message_When_Quantity_Larger_Than_Stock_Create_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var sale = new Sale(); sale.ProductId = 1; sale.Quantity = 300; var newSale = await service.Create(sale); Assert.Equal("{ Message = Quantidade indisponível no estoque. }", newSale.ToString()); } }
public void Test_Return_Message_When_Product_NotFound_Create_Sale_Service() { var fakeContext = new FakeContext("Return_Message_When_Product_NotFound_Create_Sale_Service"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var productRepository = new ProductRepository(context); var updateMock = new Mock <IUpdateProduct>(); updateMock .Setup(x => x.UpdateStock(It.IsAny <Sale>(), It.IsAny <Sale>())); var messageMock = new Mock <IMessageHandler>(); messageMock .Setup(x => x .SendMessageAsync(It.IsAny <MessageType>(), It.IsAny <Sale>(), It.IsAny <UpdatedSale>())) .Returns(Task.CompletedTask); var service = new SaleService(repository, messageMock.Object, updateMock.Object, productRepository); var sale = new Sale(); var newSale = service.Create(sale); Assert.Equal("{ Message = Produto não encontrado. }", newSale.Result.ToString()); } }
public dynamic GetCustomerDetailsForSalesReports(string prefix) { SaleRepository repo = new SaleRepository(); var customer = repo.GetCustomerDetailsForSalesReports(prefix); return(customer); }
public void Test_Create_Sale() { var fakeContext = new FakeContext("Create_Sale"); fakeContext.FillWith <Sale>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var fakeSale = new Sale(); fakeSale.ProductId = 1; fakeSale.Total = 1826.40M; fakeSale.Quantity = 100; fakeSale.CreatedAt = new DateTime(2020, 02, 22); fakeSale.UpdatedAt = new DateTime(2020, 08, 15); var repository = new SaleRepository(context); repository.Create(fakeSale); var createdSale = repository.GetById(6); Assert.IsType <Sale>(createdSale); Assert.Equal(6, repository.GetAll().Count()); Assert.NotEqual(0, createdSale.Id); Assert.Equal(1826.40M, createdSale.Total); Assert.Equal(100, createdSale.Quantity); Assert.Equal(new DateTime(2020, 02, 22), createdSale.CreatedAt); Assert.Equal(new DateTime(2020, 08, 15), createdSale.UpdatedAt); Assert.Equal(6, createdSale.Id); } }
public dynamic GetShowRoomCustomerDetails(string prefix) { SaleRepository repo = new SaleRepository(); var customer = repo.GetShowRoomCustomerDetails(prefix); return(customer); }
public dynamic GetReceiptNo() { SaleRepository repo = new SaleRepository(); var receiptNo = repo.GetReceiptNo(); return(receiptNo); }
public SaleProcessor(Database database, IOutgoingCommandEnvelopeRouter envelopeRouter, SaleRepository saleRepository, InventoryRepository inventoryRepository) { this.database = database; this.envelopeRouter = envelopeRouter; this.saleRepository = saleRepository; this.inventoryRepository = inventoryRepository; }
public TradeController() { this.saleRep = new SaleRepository(); this.managerRep = new ManagerRepository(); this.productRep = new ProductRepository(); formattedSales = new List<FormattedSale>(); }
//To Edit sales public dynamic GetAllSalesData() { SaleRepository repo = new SaleRepository(); dynamic getvehiclelist = repo.GetAllSalesData(); return(getvehiclelist); }
public SaleController(ApplicationDBContext context) { _saleRepo = new SaleRepository(context); _appointmentSessionRepo = new AppointmentSessionRepository(context); _callSessionRepo = new CallSessionRepository(context); _userProfileRepo = new UserProfileRepository(context); }
public PracticaUnitOfWork(string connectionString) { Customers = new CustomerRepository(connectionString); Products = new ProductRepository(connectionString); Employees = new EmployeeRepository(connectionString); Sales = new SaleRepository(connectionString); }
public dynamic GetAllLots() { SaleRepository repo = new SaleRepository(); var listLot = repo.GetAllLots(); return(listLot); }
public bool TryAddSaleWithId(Sale sale) { ResolveLocker(typeof(Sale)).EnterWriteLock(); try { var clientId = sale.Client.Id; Expression <Func <Item, bool> > itemSearchCriteria = x => x.Name == sale.Item.Name; var itemId = GetEntityId(itemSearchCriteria, ItemRepository); var dataSourceId = sale.DataSource.Id; SaleRepository.Add(new EF.Sale { Date = sale.Date, SaleSum = sale.SaleSum, ClientId = clientId, DataSourceId = dataSourceId, ItemId = itemId }); SaleRepository.Save(); return(true); } catch (Exception) { throw new ObjectAdditionException(sale); } finally { ResolveLocker(typeof(Sale)).ExitWriteLock(); } }
public dynamic GetVehiclesDataBySalesDate(DateTime salesDate) { SaleRepository repo = new SaleRepository(); var getvehiclelist = repo.GetVehiclesDataBySalesDate(salesDate); return(getvehiclelist); }
public dynamic GetSalesFrontEndID() { SaleRepository repo = new SaleRepository(); var SalesFrontEndID = repo.GetSalesFrontEndID(); return(SalesFrontEndID); }
public void Test_UpdateStock(int id) { var fakeContext = new FakeContext("UpdateProduct_Helper"); fakeContext.FillWithAll(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var productRepository = new ProductRepository(context); var repository = new SaleRepository(context); var productService = new Mock <IProductService>(); productService.Setup(x => x.GetById(It.IsAny <int>())).Returns(productRepository.GetById(id)); productService.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <Product>())) .Returns <int, Product>((productId, product) => "{ Message = Produto alterado com sucesso. }"); var update = new UpdateProduct(productService.Object); var oldSale = repository.GetById(id); var newSale = new Sale(); newSale.ProductId = id; newSale.Quantity = 15; update.UpdateStock(newSale, oldSale); Assert.Equal(115, productRepository.GetById(id).Quantity); } }
public static string PrepareTicketResponse(string ticketRequest) { string userId = ticketRequest; Console.WriteLine($" Ticket input: \n" + $"userId: {userId}\n"); SaleRepository saleRepository = new SaleRepository(); List <Sale> saleResults = saleRepository.GetUserSales(Convert.ToInt32(userId)); RouteRepository routeRepository = new RouteRepository(); string resultString = ""; foreach (Sale sale in saleResults) { Route route = routeRepository.Get(sale.route_id); List <TrainConnection> result = routeRepository.SearchForTrainConnection(route.departure_date, sale.from_station, sale.to_station); decimal price = 0; TimeSpan time = new TimeSpan(); TimeSpan hour = new TimeSpan(); foreach (TrainConnection r in result) { if (r.travel_id == route.id) { price = r.total_price; time = r.total_duration; hour = r.departure_hour; } } string saleTicketNameAmountPercentage = saleRepository.GetSaleTicketNameAmountPercentage(sale.id); string[] saleTicketNameAmountPercentagArray = saleTicketNameAmountPercentage.Split(','); var ticketName = saleTicketNameAmountPercentagArray[0]; var ticketsAmount = saleTicketNameAmountPercentagArray[1]; var ticketPercentage = saleTicketNameAmountPercentagArray[2]; var totalPrice = price * (Convert.ToInt32(ticketsAmount)) * (Convert.ToDecimal(ticketPercentage) / 100); //(Convert.ToInt32(ticketPercentage) / 100.0) * TicketResponse ticketResponse = new TicketResponse( route.train_name.ToString(), sale.from_station, sale.to_station, sale.sale_date.ToString(), route.departure_date.ToString(), hour.ToString(), totalPrice.ToString(), time.ToString(), sale.payment_status.ToString(), ticketName, ticketsAmount); resultString += ticketResponse.ToString() + ';'; } resultString = resultString.Remove(resultString.Length - 1, 1); return(resultString); }
public bool DeleteSalesLot(int id) { bool status = false; SaleRepository repo = new SaleRepository(); status = repo.DeleteSalesLot(id); return(status); }
public UnitOfWork(ApplicationContext context) { _context = context; Clients = new ClientRepository(context); Orders = new OrderRepository(context); Books = new BookRepository(context); Sales = new SaleRepository(context); }
public bool DeletePreviousSalesPayment(long id) { bool status = false; SaleRepository repo = new SaleRepository(); status = repo.DeletePreviousSalesPayment(id); return(status); }
public DAO() { Log.Trace("DAO start creating."); Context = new StoreContext(); ClientRepository = new ClientRepository(Context); GoodsRepository = new GoodsRepository(Context); ManagerRepository = new ManagerRepository(Context); SaleRepository = new SaleRepository(Context); Log.Trace("DAO created."); }
/// <summary> /// Creates new instance of sale presenter /// </summary> /// <param name="view">View to bind to</param> public SalePresenter(IViewSale view) { // Bind to all view events _view = view; _view.Add += View_Add; _view.Get += View_Get; _view.GetAll += View_GetAll; _view.Remove += View_Remove; _view.Edit += View_Edit; _view.Update += View_Update; // Create a new repository var sessionFactManager = new SessionFactoryManager(); SessionContext = new SessionContext(sessionFactManager); _saleRepository = new SaleRepository<Sale>(SessionContext); }
public RepositoryManager() { this.userRepository = new UserRepository(); try { this.userRepository.InitComponents(); } catch (UserRepository.InvalidFile) { this.userRepository.InitializeFile(); } this.productRepository = new ProductRepository(); try { this.productRepository.InitComponents(); } catch (ProductRepository.InvalidFile) { this.productRepository.InitializeFile(); } this.customerRepository = new CustomerRepository(); try { this.customerRepository.InitComponents(); } catch (CustomerRepository.InvalidFile) { this.customerRepository.InitializeFile(); } this.saleRepository = new SaleRepository(productRepository, customerRepository); try { this.saleRepository.InitComponents(); } catch (SaleRepository.InvalidFile) { this.saleRepository.InitializeFile(); } }
/// <summary> /// Sync logic for sale table /// </summary> private void SyncTable_Sale() { var localTable = new SaleRepository<Sale>(_localSessionContext); var remoteTable = new SaleRepository<Sale>(_remoteSessionContext); OnSyncStart?.Invoke(this, new SyncStartedArgs("Sale")); #region SyncCode var count = 0; var total = localTable.Count(); foreach (var row in localTable.GetAll()) { // Find a sync record that matches our related column var recordProduct = _recordRepository.GetByLocalId(row.ProductId, "product_table"); var recordStore = _recordRepository.GetByLocalId(row.StoreId, "store_table"); // Update our related column with the remote ID to prevent reference errors // Update product relation if (recordProduct != null) row.ProductId = recordProduct.Remote_Id; // Update store relation if (recordStore != null) row.StoreId = recordStore.Remote_Id; // Copy object and save (this removes ID) var newObject = ObjectCopy.Copy(row); remoteTable.Save(newObject); // Save changes to remote remoteTable.Commit(); OnUpdateStatus?.Invoke(this, new ProgressEventArgs("Synced entity " + ++count + "/" + total)); // Remove after successful remove localTable.Remove(row); localTable.Commit(); } #endregion }
public EditByAdminController() { this.saleRep = new SaleRepository(); this. managerRep = new ManagerRepository(); this.productRep = new ProductRepository(); }
public OrderProcessor(Database database, IOutgoingCommandEnvelopeRouter envelopeRouter, SaleRepository saleRepository) { this.database = database; this.envelopeRouter = envelopeRouter; this.saleRepository = saleRepository; }