/// <summary> /// Delete Order Detail Line Item /// </summary> /// <param name="orderDetailID"></param> /// <param name="transaction"></param> public void DeleteOrderDetailLineItem(Guid orderDetailID, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); OrdersBusinessRules ordersBusinessRules = new OrdersBusinessRules(); try { ordersDataService.CreateSession(); ordersDataService.BeginTransaction(); ordersDataService.DeleteOrderDetailLineItem(orderDetailID); ordersDataService.CommitTransaction(true); transaction.ReturnStatus = true; } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { ordersDataService.CloseSession(); } }
/// <summary> /// Create Order /// </summary> /// <param name="customerID"></param> /// <param name="requiredDate"></param> /// <param name="shipName"></param> /// <param name="shipAddress"></param> /// <param name="shipCity"></param> /// <param name="shipRegion"></param> /// <param name="shipPostalCode"></param> /// <param name="shipCountry"></param> /// <param name="shipperID"></param> /// <param name="transaction"></param> /// <returns></returns> public Order CreateOrder(Guid customerID, DateTime requiredDate, string shipName, string shipAddress, string shipCity, string shipRegion, string shipPostalCode, string shipCountry, int shipperID, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); OrdersBusinessRules ordersBusinessRules = new OrdersBusinessRules(); Order order = new Order(); order.CustomerID = customerID; order.OrderDate = DateTime.Now; order.RequiredDate = requiredDate; order.ShipAddress = shipAddress; order.ShipName = shipName; order.ShipCity = shipCity; order.ShipPostalCode = shipPostalCode; order.ShipRegion = shipRegion; order.ShipCountry = shipCountry; order.ShipVia = shipperID; order.OrderTotal = 0.00m; try { ordersDataService.CreateSession(); ordersBusinessRules.ValidateOrder(order, ordersDataService); if (ordersBusinessRules.ValidationStatus == true) { ordersDataService.BeginTransaction(); ordersDataService.CreateOrder(order); ordersDataService.CommitTransaction(true); transaction.ReturnStatus = true; transaction.ReturnMessage.Add("Order successfully created."); } else { transaction.ReturnStatus = ordersBusinessRules.ValidationStatus; transaction.ReturnMessage = ordersBusinessRules.ValidationMessage; transaction.ValidationErrors = ordersBusinessRules.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { ordersDataService.CloseSession(); } return(order); }
/// <summary> /// Update Order Detail Line Item /// </summary> /// <param name="orderID"></param> /// <param name="orderDetailID"></param> /// <param name="quantity"></param> /// <param name="transaction"></param> /// <returns></returns> public OrderDetail UpdateOrderDetailLineItem(long orderID, Guid orderDetailID, int quantity, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); OrdersBusinessRules ordersBusinessRules = new OrdersBusinessRules(); OrderDetail order = new OrderDetail(); order.Quantity = quantity; order.OrderDetailID = orderDetailID; order.OrderID = orderID; try { ordersDataService.CreateSession(); ordersBusinessRules.ValidateOrderDetailLineItem(order, ordersDataService); if (ordersBusinessRules.ValidationStatus == true) { ordersDataService.BeginTransaction(); ordersDataService.UpdateOrderDetailLineItem(order); ordersDataService.CommitTransaction(true); transaction.ReturnStatus = true; transaction.ReturnMessage.Add("Order line item successfully updated."); } else { transaction.ReturnStatus = ordersBusinessRules.ValidationStatus; transaction.ReturnMessage = ordersBusinessRules.ValidationMessage; transaction.ValidationErrors = ordersBusinessRules.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List <string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { ordersDataService.CloseSession(); } return(order); }
/// <summary> /// Create Order /// </summary> /// <param name="customerID"></param> /// <param name="requiredDate"></param> /// <param name="shipName"></param> /// <param name="shipAddress"></param> /// <param name="shipCity"></param> /// <param name="shipRegion"></param> /// <param name="shipPostalCode"></param> /// <param name="shipCountry"></param> /// <param name="shipperID"></param> /// <param name="transaction"></param> /// <returns></returns> public Order CreateOrder(Guid customerID, DateTime requiredDate, string shipName, string shipAddress, string shipCity, string shipRegion, string shipPostalCode, string shipCountry, int shipperID, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); OrdersBusinessRules ordersBusinessRules = new OrdersBusinessRules(); Order order = new Order(); order.CustomerID = customerID; order.OrderDate = DateTime.Now; order.RequiredDate = requiredDate; order.ShipAddress = shipAddress; order.ShipName = shipName; order.ShipCity = shipCity; order.ShipPostalCode = shipPostalCode; order.ShipRegion = shipRegion; order.ShipCountry = shipCountry; order.ShipVia = shipperID; order.OrderTotal = 0.00m; try { ordersDataService.CreateSession(); ordersBusinessRules.ValidateOrder(order, ordersDataService); if (ordersBusinessRules.ValidationStatus == true) { ordersDataService.BeginTransaction(); ordersDataService.CreateOrder(order); ordersDataService.CommitTransaction(true); transaction.ReturnStatus = true; transaction.ReturnMessage.Add("Order successfully created."); } else { transaction.ReturnStatus = ordersBusinessRules.ValidationStatus; transaction.ReturnMessage = ordersBusinessRules.ValidationMessage; transaction.ValidationErrors = ordersBusinessRules.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List<string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { ordersDataService.CloseSession(); } return order; }
/// <summary> /// Delete Order Detail Line Item /// </summary> /// <param name="orderDetailID"></param> /// <param name="transaction"></param> public void DeleteOrderDetailLineItem(Guid orderDetailID, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); OrdersBusinessRules ordersBusinessRules = new OrdersBusinessRules(); try { ordersDataService.CreateSession(); ordersDataService.BeginTransaction(); ordersDataService.DeleteOrderDetailLineItem(orderDetailID); ordersDataService.CommitTransaction(true); transaction.ReturnStatus = true; } catch (Exception ex) { transaction.ReturnMessage = new List<string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { ordersDataService.CloseSession(); } }
/// <summary> /// Update Order Detail Line Item /// </summary> /// <param name="orderID"></param> /// <param name="orderDetailID"></param> /// <param name="quantity"></param> /// <param name="transaction"></param> /// <returns></returns> public OrderDetail UpdateOrderDetailLineItem(long orderID, Guid orderDetailID, int quantity, out TransactionalInformation transaction) { transaction = new TransactionalInformation(); OrdersBusinessRules ordersBusinessRules = new OrdersBusinessRules(); OrderDetail order = new OrderDetail(); order.Quantity = quantity; order.OrderDetailID = orderDetailID; order.OrderID = orderID; try { ordersDataService.CreateSession(); ordersBusinessRules.ValidateOrderDetailLineItem(order, ordersDataService); if (ordersBusinessRules.ValidationStatus == true) { ordersDataService.BeginTransaction(); ordersDataService.UpdateOrderDetailLineItem(order); ordersDataService.CommitTransaction(true); transaction.ReturnStatus = true; transaction.ReturnMessage.Add("Order line item successfully updated."); } else { transaction.ReturnStatus = ordersBusinessRules.ValidationStatus; transaction.ReturnMessage = ordersBusinessRules.ValidationMessage; transaction.ValidationErrors = ordersBusinessRules.ValidationErrors; } } catch (Exception ex) { transaction.ReturnMessage = new List<string>(); string errorMessage = ex.Message; transaction.ReturnStatus = false; transaction.ReturnMessage.Add(errorMessage); } finally { ordersDataService.CloseSession(); } return order; }