public void GetNumberOfItems_Test() { //Arrange Order order = new Order() { OrderId = 1, OrderDate = DateTime.Now, CustomerId = 1, OrderDetails = new Core.Entities.TrackableCollection<OrderDetail>() { new OrderDetail(){OrderDetailsId = 1,Discount = 0,ProductId = 1, Amount = 3}, new OrderDetail(){OrderDetailsId = 1,Discount = 0,ProductId = 2, Amount = 12}, } }; //Act int numberOfItems = order.GetNumberOfItems(); //Asert Assert.AreEqual(15,numberOfItems); }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.Application.MainModule.SalesManagement.ISalesManagementService"/> /// </summary> /// <param name="order"><see cref="Microsoft.Samples.NLayerApp.Application.MainModule.SalesManagement.ISalesManagementService"/></param> public void AddOrder(Order order) { //Begin unit of work ( if Transaction is required init here a new TransactionScope element IUnitOfWork unitOfWork = _orderRepository.UnitOfWork as IUnitOfWork; _orderRepository.Add(order); //Complete changes in this unit of work unitOfWork.Commit(); }
public void AddOrder_Invoke_Test() { //Arrange using (ISalesManagementService orderService = IoCFactory.Instance.CurrentContainer.Resolve<ISalesManagementService>()) { string shippingZip = "9999"; Order order = new Order() { OrderDate = DateTime.Now, DeliveryDate = DateTime.Now.AddDays(1), ShippingAddress = "shipping address", ShippingCity = "Shipping City", ShippingName = "Shipping Name", ShippingZip = shippingZip, CustomerId = 1 }; //act orderService.AddOrder(order); List<Order> products = orderService.FindOrdersByShippingData(null, null, null, shippingZip); //assert Assert.IsNotNull(products); Assert.IsTrue(products.Count == 1); } }
private bool CanDeleteExecute(Order order) { return (order != null); }
private void DeleteExecute(Order order) { throw new InvalidOperationException("Not implemented"); }
private bool CanEditExecute(Order order) { return (order != null); }
private void EditExecute(Order order) { }
private bool CanViewExecute(Order order) { return (order != null); }
private void ViewExecute(Order order) { }
private void FixupOrder(Order previousValue) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.OrderDetails.Contains(this)) { previousValue.OrderDetails.Remove(this); } if (Order != null) { if (!Order.OrderDetails.Contains(this)) { Order.OrderDetails.Add(this); } OrderId = Order.OrderId; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("Order") && (ChangeTracker.OriginalValues["Order"] == Order)) { ChangeTracker.OriginalValues.Remove("Order"); } else { ChangeTracker.RecordOriginalValue("Order", previousValue); } if (Order != null && !Order.ChangeTracker.ChangeTrackingEnabled) { Order.StartTracking(); } } }
public VMPerformOrder() { //Initialize proxy IMainModuleService mainModuleService = ProxyLocator.GetMainModuleService(); mainModuleService = ProxyLocator.GetMainModuleService(); this._currentOrder = new Order(); }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/> /// </summary> /// <param name="order"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param> public void AddOrder(Order order) { try { //Resolve root dependencies and perform operations ISalesManagementService salesManagement = IoCFactory.Instance.CurrentContainer.Resolve<ISalesManagementService>(); salesManagement.AddOrder(order); } catch (ArgumentNullException ex) { //trace data for internal health system and return specific FaultException here! //Log and throw is a knowed anti-pattern but in this point ( entry point for clients this is admited!) //log exception for manage health system ITraceManager traceManager = IoCFactory.Instance.CurrentContainer.Resolve<ITraceManager>(); traceManager.TraceError(ex.Message); //propagate exception to client ServiceError detailedError = new ServiceError() { ErrorMessage = Resources.Messages.exception_InvalidArguments }; throw new FaultException<ServiceError>(detailedError); } }
private void SaveExecute() { try { Customer customer = null; if (ContactName != null) if (!string.IsNullOrEmpty(this.ContactName.Trim())) { MainModuleServiceClient client = new MainModuleServiceClient(); client.GetPagedCustomerAsync(new PagedCriteria() { PageIndex = 0, PageCount = 100 }); client.GetPagedCustomerCompleted += delegate(object s, GetPagedCustomerCompletedEventArgs e) { List<Customer> customers = new List<Customer>(); foreach (var item in e.Result) { customers.Add(item); } if (customers != null) { Order.Customer = (from c in customers where c.ContactName.Equals(this.ContactName.Trim(), StringComparison.InvariantCultureIgnoreCase) select c).FirstOrDefault<Customer>(); } else this.ContactName = string.Empty; if (this.Order.Customer != null) { this.Order.ChangeTracker.State = ObjectState.Added; client.AddOrderAsync(this.Order); this._currentOrder = new Order(); this.Order = new Order(); } }; } } catch (FaultException<ServiceError> ex) { MessageBox.Show(ex.Detail.ErrorMessage); } }
public VMPerformOrder() { this._currentOrder = new Order(); }