P1_TrevorGraham/MvcStoreApplication/BusinessLogic/BusinessLogic.cs
/// <summary>
/// returns an order viewmodel based on the given order id
/// </summary>
/// <param name="orderId"></param>
/// <returns></returns>
returns an order viewmodel based on the given order id
returns an order viewmodel based on the given order id
public OrderViewModel GetOrderViewModel(Guid orderId)
        {
            var order = _repository.GetOrderById(orderId);
            var cust = (Guid)SessionGetCurrentUser();
            var cartLines = _repository.GetOrderLinesForOrder(order.OrderId);
            var cartLineViewModels = new List<OrderLineViewModel>();
            double total = 0;
            foreach (OrderLine line in cartLines)
            {
                var viewLine = _mapper.ConvertOrderLineToOrderLineViewModel(line);
                total += viewLine.TotalPrice;
                cartLineViewModels.Add(viewLine);
            }
            OrderViewModel viewModel = new OrderViewModel()
            {
                Date = DateTime.Now,
                CustomerId = cust,
                CustomerName = _repository.GetCustomerById(cust).Fname,
                OrderId = order.OrderId,
                TotalPrice = total,
                orderLines = cartLineViewModels
            };
            if (cartLines.Count() > 0)
            {
                viewModel.StoreName = cartLines[0].Inventory.Location.Name;
            }
            return viewModel;
        }
public OrderViewModel GetOrderViewModel ( Guid orderId ) { var order = _repository . GetOrderById ( orderId ) ; var cust = ( Guid ) SessionGetCurrentUser ( ) ; var cartLines = _repository . GetOrderLinesForOrder ( order . OrderId ) ; var cartLineViewModels = new List < OrderLineViewModel > ( ) ; double total = 0 ; foreach ( OrderLine line in cartLines ) { var viewLine = _mapper . ConvertOrderLineToOrderLineViewModel ( line ) ; total += viewLine . TotalPrice ; cartLineViewModels . Add ( viewLine ) ; } OrderViewModel viewModel = new OrderViewModel ( ) { Date = DateTime . Now , CustomerId = cust , CustomerName = _repository . GetCustomerById ( cust ) . Fname , OrderId = order . OrderId , TotalPrice = total , orderLines = cartLineViewModels } ; if ( cartLines . Count ( ) > 0 ) { viewModel . StoreName = cartLines [ 0 ] . Inventory . Location . Name ; } return viewModel ; }
returns an order viewmodel based on the given order id
returns an order viewmodel based on the given order id
//if (!CurrentUserIsCustomer()) { return null; } //if (SessionGetCurrentUser() != null) { return null; } //var loc = (Guid)SessionGetCurrentLocation(); //var cart = _repository.GetOpenCartForCustomer(cust); //StoreName = _repository.GetLocationById(loc).Name,
None
orderId
Guid
None