public void TestInitialize() { context = new ApplicationDbContext(); purchaseOrderService = new PurchaseOrderService(context); purchaseOrderRepository = new PurchaseOrderRepository(context); purchaseOrderDetailRepository = new PurchaseOrderDetailRepository(context); statusRepository = new StatusRepository(context); itemRepository = new ItemRepository(context); itemPriceRepository = new ItemPriceRepository(context); supplierRepository = new SupplierRepository(context); deliveryOrderRepository = new DeliveryOrderRepository(context); deliveryOrderDetailRepository = new DeliveryOrderDetailRepository(context); }
public Home() { InitializeComponent(); brandRepo = new BrandRepository(); departmentRepo = new DepartmentRepository(); employeeRepo = new EmployeeRepository(); itemRepo = new ItemRepository(); userRepo = new UserRepository(); itemRequestRepo = new ItemRequestRepository(); providerRepo = new ProviderRepository(); purchaseOrderRepo = new PurchaseOrderRepository(); // statusRepo = new GenericRepository<Status>(); unitRepo = new UnitRepository(); }
public SchemaRepositoryContainer() { #region Entity Repositories PurchaseOrderLine = new PurchaseOrderLineRepository(); PurchaseOrder = new PurchaseOrderRepository(); SupplierCategory = new SupplierCategoryRepository(); SupplierCategories_Archive = new SupplierCategories_ArchiveRepository(); Supplier = new SupplierRepository(); Suppliers_Archive = new Suppliers_ArchiveRepository(); SupplierTransaction = new SupplierTransactionRepository(); #endregion // If not implemented this method is removed during compilation LoadCustomRepositories(); }
public void TestCleanup() { // Delete DeliveryOrders var deliveryOrderRepository = new DeliveryOrderRepository(context); if (deliveryOrderRepository.FindAll().Where(x => x.InvoiceFileName == "IDSERVICETEST").Count() > 0) { deliveryOrderRepository.FindAll().Where(x => x.InvoiceFileName == "IDSERVICETEST").ToList().ForEach(x => deliveryOrderRepository.Delete(x)); } // Delete Disbursements var disbursementRepository = new DisbursementRepository(context); if (disbursementRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").Count() > 0) { disbursementRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").ToList().ForEach(x => disbursementRepository.Delete(x)); } // Delete Purchase Orders var purchaseOrderRepository = new PurchaseOrderRepository(context); if (purchaseOrderRepository.FindAll().Where(x => x.Status.StatusId == 16).Count() > 0) { purchaseOrderRepository.FindAll().Where(x => x.Status.StatusId == 16).ToList().ForEach(x => purchaseOrderRepository.Delete(x)); } // Delete Requisitions var requisitionRepository = new RequisitionRepository(context); if (requisitionRepository.FindAll().Where(x => x.EmployeeRemarks == "IDSERVICETEST").Count() > 0) { requisitionRepository.FindAll().Where(x => x.EmployeeRemarks == "IDSERVICETEST").ToList().ForEach(x => requisitionRepository.Delete(x)); } // Delete Retrievals var retrievalRepository = new RetrievalRepository(context); if (retrievalRepository.FindAll().Where(x => x.Status.StatusId == 16).Count() > 0) { retrievalRepository.FindAll().Where(x => x.Status.StatusId == 16).ToList().ForEach(x => retrievalRepository.Delete(x)); } // Delete StockAdjustments var stockAdjustmentRepository = new StockAdjustmentRepository(context); if (stockAdjustmentRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").Count() > 0) { stockAdjustmentRepository.FindAll().Where(x => x.Remarks == "IDSERVICETEST").ToList().ForEach(x => stockAdjustmentRepository.Delete(x)); } }
/// <summary> /// Occurs when RunWorkerAsync is called. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param> private void LoadPurchaseOrdersBackground(object sender, DoWorkEventArgs e) { IPurchaseOrderRepository purchaseOrderRepository = new PurchaseOrderRepository(); BackgroundWorker source = (BackgroundWorker)sender; var results = purchaseOrderRepository.GetAllPurchaseOrders(); int index = 0; foreach (var item in results) { Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { })); source.ReportProgress(++index, item); } }
public bool UpdatePurchaseOrder(Domain.BE.PurchaseOrder purchaseOrder) { try { PurchaseOrderRepository repo = new PurchaseOrderRepository(context); repo.Update(purchaseOrder); return(true); } catch (Exception ex) { return(false); } }
// GET: Order/Edit/5 public ActionResult Edit(int id) { OrderStatusRepository orderStatusRepo = new OrderStatusRepository(); CustomerRepository custRepo = new CustomerRepository(); PurchaseOrderRepository purchaseOrder = new PurchaseOrderRepository(); PurchaseItemsRepository purchaseItemsRepo = new PurchaseItemsRepository(); SKURepository skuRepo = new SKURepository(); var list = new List <ItemListViewModel>(); var order = purchaseOrder.GetPurchaseOrders().Find(m => m.Id == id); var purchaseItems = purchaseItemsRepo.GetPurchaseItems().Where(x => x.PurchaseOrderId == order.Id).ToList(); var skus = skuRepo.GetSKUs(); var itemList = from purchaseItem in purchaseItems join sku in skus on purchaseItem.SKUId equals sku.Id select new { SKU = sku.Name, Quantity = purchaseItem.Quantity, Price = purchaseItem.Price, PurchaseItemId = purchaseItem.Id }; foreach (var item in itemList) { list.Add( new ItemListViewModel { SKU = item.SKU, Quantity = item.Quantity, Price = item.Price, PurchaseItemId = item.PurchaseItemId }); } order.AmountDue = purchaseItemsRepo.GetPurchaseItems().Where(x => x.PurchaseOrderId == order.Id).Sum(x => x.Price); var viewModel = new OrderTakingEditForm() { PurchaseOrder = order, OrderStatuses = orderStatusRepo.GetOrderStatus(), Customers = custRepo.GetCustomers(), Items = list }; Session["PurchaseOrderId"] = order.Id; return(View(viewModel)); }
public async Task GetPurchaseOrdersAsync_Returns_GetPurchaseOrderDtos() { //Arrange _fixture.MockPurchaseOrderService.Setup(x => x.GetPurchaseOrdersAsync(null)) .ReturnsAsync(_fixture.PurchaseOrders); var repository = new PurchaseOrderRepository(AutoMapperSingleton.Mapper, _fixture.MockPurchaseOrderService.Object, _fixture.MockUserAccessorService.Object); //Act var result = await repository.GetPurchaseOrdersAsync(); //Assert var orders = result.Should().BeAssignableTo <IEnumerable <GetPurchaseOrderDto> >().Subject; orders.Should().HaveCount(4); }
public static Bus Boot(PurchaseOrderRepository orderRepo, CustomerDetailsRepository customerDetailsRepository) { var bus = new Bus(); var cMembershipsRepo = new CustomerMembershipsRepository(); var ssRepo = new ShippingSlipRepository(); var orderProcessor = new OrderProcessor(orderRepo, bus); var slipGenerator = new ShippingSlipGenerator(customerDetailsRepository, ssRepo); var membershipActivator = new MembershipActivator(cMembershipsRepo); bus.Register <ShippingSlipCreated>(slipGenerator.Handle); bus.Register <MembershipActivated>(membershipActivator.Handle); bus.Register <ProcessOrder>(orderProcessor.Handle); return(bus); }
public static string GetNewPurchaseOrderNo(ApplicationDbContext context) { string prefix = "PO"; int serialNo = new PurchaseOrderRepository(context) .FindByCreatedDateTime(DateTime.Now.Date.AddDays(1 - DateTime.Now.Date.Day), DateTime.Now.Date.AddDays(1)) .Where(x => x.PurchaseOrderNo.Length == 13) .Count() > 0 ? new PurchaseOrderRepository(context) .FindByCreatedDateTime(DateTime.Now.Date.AddDays(1 - DateTime.Now.Date.Day), DateTime.Now.Date.AddDays(1)) .Where(x => x.PurchaseOrderNo.Length == 13) .AsEnumerable() .Select(x => Int32.Parse(x.PurchaseOrderNo.Substring(x.PurchaseOrderNo.Length - 3))) .OrderByDescending(x => x) .FirstOrDefault() + 1 : 1; return($"{prefix}-{DateTime.Now.Year}{DateTime.Now.Month:00}-{serialNo:000}"); }
public UnitOfWork(AppDbContext context) { _context = context; Mobiles = new MobileRepository(_context); Accessories = new AccessoryRepository(_context); AccessoryTypes = new AccessoryTypeRepository(_context); Brands = new BrandRepository(_context); Vendors = new VendorRepository(_context); Orders = new OrderRepository(_context); OrderLineItems = new OrderLineItemRepository(_context); Invoices = new InvoiceRepository(_context); InvoiceLineItems = new InvoiceLineItemRepository(_context); Categories = new CategoryRepository(_context); Customers = new CustomerRepository(_context); PurchaseOrders = new PurchaseOrderRepository(_context); PurchaseLineItems = new PurchaseLineItemRepository(_context); }
/// <summary> /// 结算采购单 /// </summary> /// <param name="model"></param> public void Settlement(PurchaseSettlementModel model) { if (model == null) { return; } if (model.SettlementAmount <= 0) { throw new Exception("请填写结算金额。"); } var order = PurchaseOrderRepository.GetModel(model.PurchaseOrderId); if (order == null) { throw new Exception("采购单不存在。"); } if (order.Status != EnumPurchaseOrderStatus.Completed) { throw new Exception("只能结算已全部到货的采购单。"); } if (order.SettlementStatus != EnumSettlementStatus.Waiting && order.SettlementStatus != EnumSettlementStatus.PartCompleted) { throw new Exception("只能结算待结算的采购单。"); } order.SettlementStatus = model.SettlementStatus; order.SettlementAmount = order.SettlementAmount + model.SettlementAmount; if (order.SettlementAmount >= order.Amount && order.SettlementStatus == EnumSettlementStatus.PartCompleted) { throw new Exception("结算金额已超过采购单总金额,不允许部分结算。"); } var financeOrder = new FinanceOrder(); financeOrder.Code = this.FinanceOrderRepository.GetSequenceNextCode(); financeOrder.Amount = model.SettlementAmount; financeOrder.Remark = model.SettlementRemark; this.PurchaseOrderRepository.Settlement(order, financeOrder); }
public IActionResult CompleteBoosterJob(int Id) { var result = PurchaseOrderRepository.GetPurchaseForm(Id); var id = User.FindFirst(ClaimTypes.NameIdentifier).Value; var user = _userManager.FindByIdAsync(id).Result; if (result.JobAvailable != true && !result.BoosterCompletionConfirmed && result.BoosterAssignedTo == user) { result.BoosterCompletionConfirmed = true; PurchaseOrderRepository.Update(result); AuditRepository.Add(new LeagueOfLegendsAuditModel { User = user, DateTime = DateTime.UtcNow, Action = $"Completed Job By Booster [{JsonConvert.SerializeObject(result)}]" }); return(Json(true)); } return(Json(false)); }
public async Task DeletePurchaseOrderAsync_Returns_NoResult() { //Arrange var id = 2; _fixture.MockPurchaseOrderService.Setup(x => x.GetPurchaseOrderAsync(It.IsAny <Expression <Func <PurchaseOrder, bool> > >())) .Returns <Expression <Func <PurchaseOrder, bool> > >(expression => Task.FromResult(_fixture.PurchaseOrders.AsQueryable().FirstOrDefault(expression))); _fixture.MockPurchaseOrderService.Setup(x => x.DeletePurchaseOrderAsync(It.IsAny <PurchaseOrder>())); var repository = new PurchaseOrderRepository(AutoMapperSingleton.Mapper, _fixture.MockPurchaseOrderService.Object, _fixture.MockUserAccessorService.Object); //Act await repository.DeletePurchaseOrderAsync(id); // Assert _fixture.MockPurchaseOrderService.Verify(x => x.DeletePurchaseOrderAsync(It.IsAny <PurchaseOrder>()), Times.Once); }
public async Task GetPurchaseOrderAsync_Throws_NotFoundException() { //Arrange var id = 201; _fixture.MockPurchaseOrderService.Setup(x => x.GetPurchaseOrderAsync(It.IsAny <Expression <Func <PurchaseOrder, bool> > >())) .Returns <Expression <Func <PurchaseOrder, bool> > >(expression => Task.FromResult(_fixture.PurchaseOrders.AsQueryable().FirstOrDefault(expression))); var repository = new PurchaseOrderRepository(AutoMapperSingleton.Mapper, _fixture.MockPurchaseOrderService.Object, _fixture.MockUserAccessorService.Object); //Act var exception = await Assert.ThrowsAsync <RestException>(() => repository.GetPurchaseOrderAsync(id)); //Assert exception.ErrorCode.Should().Be(HttpStatusCode.NotFound); exception.ErrorMessage.Should().Be("Purchase order not found."); exception.ErrorType.Should().Be(HttpStatusCode.NotFound.ToString()); }
public async Task CreatePurchaseOrderAsync_Returns_New_GetPurchaseOrderDto() { //Arrange _fixture.MockPurchaseOrderService.Setup(x => x.AddPurchaseOrderAsync(It.IsAny <PurchaseOrder>())) .ReturnsAsync(_fixture.CreatedNewPurchaseOrder); _fixture.MockUserAccessorService.Setup(x => x.GetCurrentUser()).Returns(_fixture.CurrentUser); var repository = new PurchaseOrderRepository(AutoMapperSingleton.Mapper, _fixture.MockPurchaseOrderService.Object, _fixture.MockUserAccessorService.Object); //Act var result = await repository.CreatePurchaseOrderAsync(_fixture.CreatePurchaseOrderDto); //Assert result.Should().BeOfType(typeof(GetPurchaseOrderDto)); result.Id.Should().Be(5); result.OrderNumber.Should().Be("PO_20210227_8d8c512f7cd7920"); result.SupplierName.Should().Be("VBT Pvt Ltd"); }
public async Task GetPurchaseOrderAsync_Returns_GetPurchaseOrderDto() { //Arrange var id = 1; _fixture.MockPurchaseOrderService.Setup(x => x.GetPurchaseOrderAsync(It.IsAny <Expression <Func <PurchaseOrder, bool> > >())) .Returns <Expression <Func <PurchaseOrder, bool> > >(expression => Task.FromResult(_fixture.PurchaseOrders.AsQueryable().FirstOrDefault(expression))); var repository = new PurchaseOrderRepository(AutoMapperSingleton.Mapper, _fixture.MockPurchaseOrderService.Object, _fixture.MockUserAccessorService.Object); //Act var result = await repository.GetPurchaseOrderAsync(id); //Assert result.Should().BeOfType(typeof(GetPurchaseOrderDto)); result.Id.Should().Be(id); result.OrderNumber.Should().Be("PO_20210130_8d8c510caee6a4b"); result.SupplierName.Should().Be("ABC Pvt Ltd"); }
public IActionResult OrderDetails([FromQuery(Name = "hash")] string hash) { LolOrderDetailsViewModel LolOrderDetailsViewModel = new LolOrderDetailsViewModel(); var user = _userManager.FindByIdAsync(User.FindFirst(ClaimTypes.NameIdentifier).Value).Result; LolOrderDetailsViewModel.CurrentUser = user; if (User.IsInRole("Superuser")) { LolOrderDetailsViewModel.PurchaseForm = PurchaseOrderRepository.GetPurchaseFormModelsIncludedById(int.Parse(EncryptionHelper.Decrypt(hash))); LolOrderDetailsViewModel.ChatModel = ChatModelRepository.GetChatModelByPurchaseOrder(int.Parse(EncryptionHelper.Decrypt(hash))); return(View(LolOrderDetailsViewModel)); } else { LolOrderDetailsViewModel.PurchaseForm = PurchaseOrderRepository.GetPurchaseFormModelsIncludedByIdAndUser(int.Parse(EncryptionHelper.Decrypt(hash)), user); LolOrderDetailsViewModel.ChatModel = ChatModelRepository.GetChatModelByPurchaseOrder(int.Parse(EncryptionHelper.Decrypt(hash))); return(View(LolOrderDetailsViewModel)); } }
public async Task GetPurchaseOrdersAllowToCreateGRN_Returns_GetPurchaseOrderDtos() { //Arrange _fixture.MockPurchaseOrderService.Setup(x => x.GetPurchaseOrdersAsync(It.IsAny <Expression <Func <PurchaseOrder, bool> > >())) .Returns <Expression <Func <PurchaseOrder, bool> > >(async(expression) => { var orders = _fixture.PurchaseOrders.AsQueryable().Where(expression).ToList(); return(await Task.FromResult(orders)); }); var repository = new PurchaseOrderRepository(AutoMapperSingleton.Mapper, _fixture.MockPurchaseOrderService.Object, _fixture.MockUserAccessorService.Object); //Act var result = await repository.GetPurchaseOrdersAllowToCreateGRN(); //Assert var orders = result.Should().BeAssignableTo <IEnumerable <GetPurchaseOrderDto> >().Subject; orders.Should().HaveCount(2); }
public UnitOfWork(RestProContext context) { _context = context; Users = new UserRepository(_context); WorkCycles = new WorkCycleRepository(_context); UserAuthenticationService = new UserAuthenticationService(new UserRepository(_context)); Suppliers = new SupplierRepository(_context); Statuses = new StatusRepository(_context); PurchaseOrders = new PurchaseOrderRepository(_context); RawMaterials = new RawMaterialsRepository(_context); RawMaterialCategories = new RawMaterialCategoryRepository(_context); Locations = new LocationRepository(_context); InventorySettings = new InventorySettingsRepository(_context); WorkCycleStatuses = new WorkCycleStatusRepository(_context); PurchaseOrderTransactions = new PurchaseOrderTransactionRepository(_context); WorkCycleTransactions = new WorkCycleTransactionRepository(_context); WorkCyclesLines = new WorkCycleLineRepository(_context); Inventory = new InventoryRepository(_context); InventoryTransactionRepository = new InventoryTransactionsRepository(_context); }
public UnitOfWork(ApplicationDbContext context) { _context = context; StockItems = new StockRepository(_context); Invoices = new InvoiceRepository(_context); JobCards = new JobCardRepository(_context); JobStatuses = new JobStatusRepository(_context); Suppliers = new SupplierRepository(_context); JobTypes = new JobTypeRepository(_context); Customers = new CustomerRepository(_context); ServiceContracts = new ServiceContractRepository(_context); MaintenanceContracts = new MaintenanceContractRepository(_context); Areas = new AreaRepository(_context); PurchaseOrders = new PurchaseOrderRepository(_context); PurchaseOrderItems = new PurchaseOrderItemRepository(_context); ApplicationUserSignatures = new ApplicationUserSignatureRepository(_context); CustomerSignatures = new CustomerSignatureRepository(_context); JobStatusHistory = new JobStatusHistoryRepository(_context); Quotes = new QuotationRepository(_context); StockItemQuantities = new StockItemQuantityRepository(_context); }
public PurchaseOrderForm(string mode, DataGridViewRow row) { InitializeComponent(); _Context = new PurchaseContext(); purchaseOrderRepo = new PurchaseOrderRepository(); purchase = new PurchaseOrderDto(); if (mode != null) { this.mode = mode; if (this.mode.Equals("Create")) { Text = "Crear Solicitud de Articulo"; } if (this.mode.Equals("Edit")) { Text = "Editar Solicitud de Articulo"; this.row = row; } } }
public async Task ApprovalPurchaseOrderAsync_Throws_UserId_BadRequestException() { //Arrange var id = 2; _fixture.MockPurchaseOrderService.Setup(x => x.GetPurchaseOrderAsync(It.IsAny <Expression <Func <PurchaseOrder, bool> > >())) .Returns <Expression <Func <PurchaseOrder, bool> > >(expression => Task.FromResult(_fixture.PurchaseOrders.AsQueryable().FirstOrDefault(expression))); _fixture.MockPurchaseOrderService.Setup(x => x.UpdatePurchaseOrderAsync(It.IsAny <PurchaseOrder>())) .Returns(Task.FromResult(_fixture.ApprovedPurchaseOrder)); _fixture.MockUserAccessorService.Setup(x => x.GetCurrentUser()).Returns(_fixture.EmptyUserIdCurrentUser); var repository = new PurchaseOrderRepository(AutoMapperSingleton.Mapper, _fixture.MockPurchaseOrderService.Object, _fixture.MockUserAccessorService.Object); //Act var exception = await Assert.ThrowsAsync <RestException>(() => repository.ApprovalPurchaseOrderAsync(id, _fixture.ApprovalPurchaseOrderDto)); //Assert exception.ErrorCode.Should().Be(HttpStatusCode.BadRequest); exception.ErrorMessage.Should().Be("User details not found. Login again."); exception.ErrorType.Should().Be(HttpStatusCode.BadRequest.ToString()); }
/// <summary> /// 设置已到货 /// </summary> /// <param name="Id"></param> public void SetArrival(IList <Guid> IdList) { if (IdList == null || !IdList.Any()) { return; } foreach (var Id in IdList) { var order = PurchaseOrderRepository.GetModel(Id); if (order == null) { continue; } if (order.Status != EnumPurchaseOrderStatus.Purchasing) { throw new Exception("只能将采购中的采购单设置为已到货。"); } this.PurchaseOrderRepository.SetArrival(order); } }
public async Task ApprovalPurchaseOrderAsync_Returns_Approval_GetPurchaseOrderDto() { //Arrange var id = 2; _fixture.MockPurchaseOrderService.Setup(x => x.GetPurchaseOrderAsync(It.IsAny <Expression <Func <PurchaseOrder, bool> > >())) .Returns <Expression <Func <PurchaseOrder, bool> > >(expression => Task.FromResult(_fixture.PurchaseOrders.AsQueryable().FirstOrDefault(expression))); _fixture.MockPurchaseOrderService.Setup(x => x.UpdatePurchaseOrderAsync(It.IsAny <PurchaseOrder>())) .Returns(Task.FromResult(_fixture.ApprovedPurchaseOrder)); _fixture.MockUserAccessorService.Setup(x => x.GetCurrentUser()).Returns(_fixture.CurrentUser); var repository = new PurchaseOrderRepository(AutoMapperSingleton.Mapper, _fixture.MockPurchaseOrderService.Object, _fixture.MockUserAccessorService.Object); //Act var result = await repository.ApprovalPurchaseOrderAsync(id, _fixture.ApprovalPurchaseOrderDto); //Assert result.Should().BeOfType(typeof(GetPurchaseOrderDto)); result.Id.Should().Be(id); result.OrderNumber.Should().Be("PO_20210130_8d8c512f7cd7920"); result.ApprovalStatus.Should().Be("Rejected"); }
public void CreateOrUpdate(PurchaseOrderContract purchaseOrderContract) { var purchaseorder = PurchaseOrderRepository.Get(purchaseOrderContract.Id); if (purchaseorder != null) { purchaseorder.Code = purchaseOrderContract.Code; //purchaseorder.CreationDate = purchaseOrderContract.CreationDate; purchaseorder.Title = purchaseOrderContract.Title; for (int i = 0; i < purchaseOrderContract.PurchaseOrderItems.Count; i++) { var temp = purchaseOrderContract.PurchaseOrderItems[i]; if (purchaseorder.PurcahseOrderItems.Any(p => p.Id == temp.Id)) { var indatabasepurchaseorder = purchaseorder.PurcahseOrderItems.FirstOrDefault(p => p.Id == temp.Id); indatabasepurchaseorder.NetPrice = temp.NetPrice; indatabasepurchaseorder.Quantity = temp.Quantity; indatabasepurchaseorder.TotalPrice = temp.TotalPrice; indatabasepurchaseorder.UnitPrice = temp.UnitPrice; indatabasepurchaseorder.Item = ItemRepository.Get(temp.ItemId); indatabasepurchaseorder.Rack = RackRepository.Get(temp.RackId); } else { var purchaseorderitem = new PurchaseOrderItem(); purchaseorderitem.NetPrice = temp.NetPrice; purchaseorderitem.Quantity = temp.Quantity; purchaseorderitem.TotalPrice = temp.TotalPrice; purchaseorderitem.UnitPrice = temp.UnitPrice; purchaseorderitem.Item = ItemRepository.Get(temp.ItemId); purchaseorderitem.Rack = RackRepository.Get(temp.RackId); purchaseorder.PurcahseOrderItems.Add(purchaseorderitem); } } for (int i = 0; i < purchaseorder.PurcahseOrderItems.Count; i++) { var temp = purchaseorder.PurcahseOrderItems.ToArray()[i]; if (!purchaseOrderContract.PurchaseOrderItems.Any(p => p.Id == temp.Id)) { purchaseorder.PurcahseOrderItems.Remove(temp); } } PurchaseOrderRepository.Update(purchaseorder); } else { purchaseorder = new PurchaseOrder(); purchaseorder.Code = purchaseOrderContract.Code; purchaseorder.CreationDate = purchaseOrderContract.CreationDate; purchaseorder.Title = purchaseOrderContract.Title; for (int i = 0; i < purchaseOrderContract.PurchaseOrderItems.Count; i++) { var temp = purchaseOrderContract.PurchaseOrderItems[i]; var indatabaepurchaseorder = purchaseorder.PurcahseOrderItems.FirstOrDefault(p => p.Id == temp.Id); indatabaepurchaseorder.NetPrice = temp.NetPrice; indatabaepurchaseorder.Quantity = temp.Quantity; indatabaepurchaseorder.TotalPrice = temp.TotalPrice; indatabaepurchaseorder.UnitPrice = temp.UnitPrice; indatabaepurchaseorder.Item = ItemRepository.Get(temp.ItemId); indatabaepurchaseorder.Rack = RackRepository.Get(temp.RackId); } PurchaseOrderRepository.Insert(purchaseorder); } }
public void TestInitialize() { // Arrange context = new ApplicationDbContext(); purchaseOrderRepository = new PurchaseOrderRepository(context); }
public void Delete(PurchaseOrderContract purchaseOrderContract) { var purchaseorder = PurchaseOrderRepository.Get(purchaseOrderContract.Id); PurchaseOrderRepository.Delete(purchaseorder); }
public PurchaseOrdersService(PurchaseOrderRepository purchaseOrderRepository) { this.purchaseOrderRepository = purchaseOrderRepository; }
public RepositoryFactory() { Repository bankRepository = new Repository(new Bank()); CurrencyRepository ccyRepository = new CurrencyRepository(); Repository divRepository = new Repository(new Division()); Repository empRepository = new EmployeeRepository(new Employee()); Repository topRepository = new Repository(new TermOfPayment()); Repository unitRepository = new Repository(new Unit()); Repository cuscatRepository = new Repository(new CustomerCategory()); Repository supcatRepository = new Repository(new SupplierCategory()); Repository pricecatRepository = new Repository(new PriceCategory()); Repository taxRepository = new Repository(new Tax()); Repository prtGroupRepository = new Repository(new PartGroup()); Repository warehouseRepository = new Repository(new Warehouse()); Repository prtCategoryRepository = new Repository(new PartCategory()); Repository docTypeRepository = new Repository(new DocumentType()); Repository excRateRepository = new Repository(new ExchangeRate()); CustomerRepository customerRepository = new CustomerRepository(); SupplierRepository supplierRepository = new SupplierRepository(); Repository yearRepository = new YearRepository(); Repository partRepository = new PartRepository(new Part()); StockTakingRepository stocktakingRepository = new StockTakingRepository(); UserRepository userRepository = new UserRepository(new User()); GeneralSetupRepository generalsetupRepository = new GeneralSetupRepository(); PurchaseOrderRepository poRepository = new PurchaseOrderRepository(); PeriodRepository periodRepository = new PeriodRepository(); UserSettingsRepository usRepository = new UserSettingsRepository(); GoodReceiveNoteRepository grnRepository = new GoodReceiveNoteRepository(); PurchaseReturnRepository prRepository = new PurchaseReturnRepository(); SupplierInvoiceRepository siRepository = new SupplierInvoiceRepository(); SupplierOutStandingInvoiceRepository soiRepository = new SupplierOutStandingInvoiceRepository(); SupplierInvoiceJournalRepository sijRepository = new SupplierInvoiceJournalRepository(); PaymentRepository payRepository = new PaymentRepository(); APDebitNoteRepository apdnRepository = new APDebitNoteRepository(); ProcessTransactionRepository prtrRepository = new ProcessTransactionRepository(); SalesOrderRepository slsorderRepository = new SalesOrderRepository(); DeliveryOrderRepository doRepository = new DeliveryOrderRepository(); SalesReturnRepository srRepository = new SalesReturnRepository(); CustomerOutStandingInvoiceRepository coirRepository = new CustomerOutStandingInvoiceRepository(); CustomerInvoiceRepository cirRepository = new CustomerInvoiceRepository(); ReceiptRepository rcptRepository = new ReceiptRepository(); ARCreditNoteRepository arcrRepository = new ARCreditNoteRepository(); CustomerInvoiceJournalRepository cijRepository = new CustomerInvoiceJournalRepository(); OpeningStockRepository opstRepository = new OpeningStockRepository(); POSRepository posRepository = new POSRepository(); m_listService.Add(BANK_REPOSITORY, bankRepository); m_listService.Add(CURRENCY_REPOSITORY, ccyRepository); m_listService.Add(DIVISION_REPOSITORY, divRepository); m_listService.Add(EMPLOYEE_REPOSITORY, empRepository); m_listService.Add(TOP_REPOSITORY, topRepository); m_listService.Add(UNIT_REPOSITORY, unitRepository); m_listService.Add(CUSTOMER_CATEGORY_REPOSITORY, cuscatRepository); m_listService.Add(SUPPLIER_CATEGORY_REPOSITORY, supcatRepository); m_listService.Add(PRICE_CATEGORY_REPOSITORY, pricecatRepository); m_listService.Add(TAX_REPOSITORY, taxRepository); m_listService.Add(PART_GROUP_REPOSITORY, prtGroupRepository); m_listService.Add(WAREHOUSE_REPOSITORY, warehouseRepository); m_listService.Add(PART_CATEGORY_REPOSITORY, prtCategoryRepository); m_listService.Add(DOC_TYPE_REPOSITORY, docTypeRepository); m_listService.Add(EXCHANGE_RATE_REPOSITORY, excRateRepository); m_listService.Add(CUSTOMER_REPOSITORY, customerRepository); m_listService.Add(SUPPLIER_REPOSITORY, supplierRepository); m_listService.Add(YEAR_REPOSITORY, yearRepository); m_listService.Add(PART_REPOSITORY, partRepository); m_listService.Add(STOCKTAKING_REPOSITORY, stocktakingRepository); m_listService.Add(USER_REPOSITORY, userRepository); m_listService.Add(GENERAL_SETUP_REPOSITORY, generalsetupRepository); m_listService.Add(PURCHASEORDER_REPOSITORY, poRepository); m_listService.Add(PERIOD_REPOSITORY, periodRepository); m_listService.Add(USER_SETTING_REPOSITORY, usRepository); m_listService.Add(GOODRECEIVENOTE_REPOSITORY, grnRepository); m_listService.Add(PURCHASE_RETURN_REPOSITORY, prRepository); m_listService.Add(SUPPLIERINVOICE_REPOSITORY, siRepository); m_listService.Add(SUPPLIERINVOICE_JOURNAL_REPOSITORY, sijRepository); m_listService.Add(SUPPLIER_OUTSTANDING_INVOICE_REPOSITORY, soiRepository); m_listService.Add(PAYMENT_REPOSITORY, payRepository); m_listService.Add(APDEBITNOTE_REPOSITORY, apdnRepository); m_listService.Add(PROCESS_TRANSACTION_REPOSITORY, prtrRepository); m_listService.Add(SALES_ORDER_REPOSITORY, slsorderRepository); m_listService.Add(DELIVERY_ORDER_REPOSITORY, doRepository); m_listService.Add(SALES_RETURN_REPOSITORY, srRepository); m_listService.Add(CUSTOMER_OUTSTANDING_INVOICE_REPOSITORY, coirRepository); m_listService.Add(CUSTOMERINVOICE_REPOSITORY, cirRepository); m_listService.Add(RECEIPT_REPOSITORY, rcptRepository); m_listService.Add(ARCREDITNOTE_REPOSITORY, arcrRepository); m_listService.Add(CUSTOMERINVOICE_JOURNAL_REPOSITORY, cijRepository); m_listService.Add(OPENING_STOCK_REPOSITORY, opstRepository); m_listService.Add(POS_REPOSITORY, posRepository); }