public static SalesOrderDetailRepository GetSalesOrderDetailRepository(IUnitOfWork unitOfWork) { var repository = new SalesOrderDetailRepository(); repository.UnitOfWork = unitOfWork; return(repository); }
private void Button_Click(object sender, RoutedEventArgs e) { using (var connection = new SqlConnection("Data Source=localhost;Initial Catalog=AdventureWorks2017;Integrated Security=True;")) { connection.Open(); foreach (var salesOrderDetail in SalesOrderDetailRepository.GetSalesOrderDetail(connection)) { SalesOrderDetails.Add(salesOrderDetail); } } }
public AWUnitOfWork(AWContext context) { _context = context; Address = new AddressRepository(context); BusinessEntity = new BusinessEntityRepository(context); BusinessEntityAddress = new BusinessEntityAddressRepository(context); PersonPhone = new PersonPhoneRepository(context); StateProvince = new StateProvinceRepository(context); Customer = new CustomerRepository(context); SalesPerson = new SalesPersonRepository(context); SalesOrderHeader = new SalesOrderHeaderRepository(context); SalesOrderDetail = new SalesOrderDetailRepository(context); ShoppingCartItem = new ShoppingCartItemRepository(context); SalesTerritory = new SalesTerritoryRepository(context); Product = new ProductRepository(context); ProductCategory = new ProductCategoryRepository(context); ProductDescription = new ProductDescriptionRepository(context); ProductInventory = new ProductInventoryRepository(context); ProductListPriceHistory = new ProductListPriceHistoryRepository(context); ProductPhoto = new ProductPhotoRepository(context); ProductProductPhoto = new ProductProductPhotoRepository(context); Person = new PersonRepository(context); }
public IList<SlsDeliveryViewModel> GetAllVM() { try { IList<SlsDeliveryViewModel> list = new List<SlsDeliveryViewModel>(); IList<SlsDelivery> listM = new List<SlsDelivery>(); listM = _DeliveryRepository.GetAll(); if (listM != null && listM.Count() > 0) { list = listM.Select(x => new SlsDeliveryViewModel { Id = x.Id, SlsSalesOrderId = x.SlsSalesOrderId, DeliveryDate = x.DeliveryDate, ChallanNo = x.ChallanNo, InvoiceNo = x.InvoiceNo, VehicleNo = x.VehicleNo, Remarks = x.Remarks, Discount = x.Discount, Total = x.Total, ReceivedStatus = x.ReceivedStatus, ReceivedDate = x.ReceivedDate, ReceivedRemarks = x.ReceivedRemarks, CreatedBy = x.CreatedBy, CreatedDate = x.CreatedDate, ModifiedBy = x.ModifiedBy, ModifiedDate = x.ModifiedDate }).ToList(); if (list != null && list.Count() > 0) { IList<SlsSalesOrderDetail> salesOrderDetailList = new SalesOrderDetailRepository(new DatabaseFactory()).GetAll(); foreach (SlsDeliveryViewModel item in list) { item.SlsDeliverDetails = GetAllDeliveryDetails(item.Id).ToList(); foreach (SlsDeliverDetailViewModel itemDetail in item.SlsDeliverDetails) { //Product Ordered Number - get by sales order id, product id, unit id int? salesOrderId = item.SlsSalesOrderId; int productId = itemDetail.SlsProductId; int unitId = itemDetail.SlsUnitId; if (salesOrderId != null) { SlsSalesOrderDetail soDetailObj = salesOrderDetailList.Where(i => i.SlsSalesOrderId == salesOrderId && i.SlsProductId == productId && i.SlsUnitId == unitId).FirstOrDefault(); if (soDetailObj != null) { itemDetail.SalesOrderQuantity = soDetailObj.SalesOrderQuantity; } } } } } } return list; } catch (Exception ex) { return null; } }