Ejemplo n.º 1
0
 public OrderReturnRequest(
     MFulfillment_ReturnRequest mReturnRequest,
     IApplicationLocale locale)
 {
     MReturnRequest = mReturnRequest;
     Locale         = locale;
 }
        //#pragma warning disable CA1822 // Mark members as static
        //        public EditReturnRequest CreateEditReturnRequest(long orderId, long returnRequestId)
        //#pragma warning restore CA1822 // Mark members as static
        //        {
        //            var model = new EditReturnRequest()
        //            {
        //                OrderId = orderId,
        //                ReturnRequestId = returnRequestId
        //            };

        //            return model;
        //        }

        public EditReturnRequest CreateEditReturnRequest(
            MFulfillment_Fulfillable mFulfillable,
            IList <MFulfillment_ReturnRequestReason> mReturnRequestReasons,
            MFulfillment_ReturnRequest mReturnRequest)
        {
            var returnRequestItems = new List <EditReturnRequest.ReturnRequestItem>();

            foreach (var mFulfillableItem in mFulfillable.FulfillableItems)
            {
                // Find corresponding return request item if a return request exists.
                //
                var mReturnRequestItem = mReturnRequest?.ReturnRequestItems.Where(r => r.FulfillableItemId == mFulfillableItem.FulfillableItemId).First();

                var currentQuantity = mReturnRequestItem != null
                    ? mReturnRequestItem.Quantity
                    : 0;

                var maxQuantity = mFulfillableItem.CompleteQuantity - mFulfillableItem.ReturnQuantity;

                var returnRequestItem = new EditReturnRequest.ReturnRequestItem()
                {
                    ReturnRequestItemId      = mReturnRequestItem?.ReturnRequestItemId,
                    FulfillableItemId        = mFulfillableItem.FulfillableItemId,
                    FulfillableItemReference = mFulfillableItem.FulfillableItemReference,
                    Description = mFulfillableItem.Description,
                    Quantity    = currentQuantity,
                    MaxQuantity = maxQuantity,
                    Quantities  = GetQuantitySelectList(maxQuantity)
                };

                returnRequestItems.Add(returnRequestItem);
            }

            var currentReturnRequestType   = mReturnRequest?.ReturnRequestType.ToString();
            var currentReturnRequestReason = mReturnRequest?.ReturnRequestReasonCode;

            var model = new EditReturnRequest()
            {
                ReturnRequestId     = mReturnRequest?.ReturnRequestId,
                ReturnRequestNumber = mReturnRequest?.ReturnRequestNumber,
                FulfillableId       = mFulfillable.FulfillableId,
                FulfillableName     = mFulfillable.Name,

                ReturnRequestType  = currentReturnRequestType,
                ReturnRequestTypes = GetReturnRequestTypeSelectList(mReturnRequest == null),

                ReturnRequestReason  = currentReturnRequestReason,
                ReturnRequestReasons = GetReturnRequestReasonSelectList(mReturnRequestReasons, mReturnRequest == null),

                ReturnRequestItems = returnRequestItems
            };

            return(model);
        }
Ejemplo n.º 3
0
        public EditReturn CreateEditReturn(
            MFulfillment_Fulfillable mFulfillable,
            MFulfillment_ReturnRequest mReturnRequest,
            MFulfillment_Return mReturn)
        {
            var returnRequestItems = new List <EditReturn.ReturnItem>();

            foreach (var mReturnRequestItem in mReturnRequest.ReturnRequestItems)
            {
                var mFulfillableItem = mFulfillable.FulfillableItems.Where(r => r.FulfillableItemId == mReturnRequestItem.FulfillableItemId).First();

                var mReturnItem = mReturn?.ReturnItems.Where(r => r.ReturnRequestItemId == mReturnRequestItem.ReturnRequestItemId).First();

                var currentQuantity = mReturnItem != null
                    ? mReturnItem.Quantity
                    : 0;

                var maxQuantity = mReturnRequestItem.Quantity;

                var returnRequestItem = new EditReturn.ReturnItem()
                {
                    ReturnItemId             = mReturnItem?.ReturnItemId,
                    ReturnRequestItemId      = mReturnRequestItem.ReturnRequestItemId,
                    FulfillableItemId        = mFulfillableItem.FulfillableItemId,
                    FulfillableItemReference = mFulfillableItem.FulfillableItemReference,
                    Description = mFulfillableItem.Description,
                    Quantity    = currentQuantity,
                    MaxQuantity = maxQuantity,
                    Quantities  = GetQuantitySelectList(maxQuantity)
                };

                returnRequestItems.Add(returnRequestItem);
            }

            var model = new EditReturn()
            {
                ReturnId     = mReturn?.ReturnId,
                ReturnNumber = mReturn?.ReturnNumber,

                ReturnRequestId     = mReturnRequest.ReturnRequestId,
                ReturnRequestNumber = mReturnRequest?.ReturnRequestNumber,
                FulfillableId       = mFulfillable.FulfillableId,
                FulfillableName     = mFulfillable.Name,
                ReturnRequestType   = mReturnRequest.ReturnRequestType.ToString(),
                ReturnRequestReason = mReturnRequest.ReturnRequestReasonCode,

                ReturnDate = mReturn?.CreateDateTimeUtc,

                ReturnItems = returnRequestItems
            };

            return(model);
        }
Ejemplo n.º 4
0
            public static AReturn_ReturnRequest AReturn_ReturnRequest(
                MFulfillment_ReturnRequest mReturnRequest,
                MFulfillment_ReturnRequestTransactionSummaryList mTransactions,
                MFulfillment_ReturnRequestEventLogSummaryList mEvents,
                IList <MFulfillment_Fulfillable> mFulfillables,
                bool allowEdit)
            {
                var result = new AReturn_ReturnRequest()
                {
                    MReturnRequest = mReturnRequest,
                    MTransactions  = mTransactions,
                    MEvents        = mEvents,
                    MFulfillables  = mFulfillables,
                    AllowEdit      = allowEdit
                };

                return(result);
            }
        public ReturnRequestViewModel CreateReturnRequestViewModel(UOrder_Order fromOrder, MFulfillment_ReturnRequest fromReturnRequest, IReadOnlyList <MFulfillment_ReturnRequestReason> fromReturnRequestReasons)
        {
            var to = new ReturnRequestViewModel();

            if (fromReturnRequest != null)
            {
                CopyReturnRequestViewModel(to, fromOrder, fromReturnRequest, fromReturnRequestReasons);
            }
            else
            {
                CopyReturnRequestViewModel(to, fromOrder);
            }
            return(to);
        }
        private void CopyReturnRequestViewModel(ReturnRequestViewModel to, UOrder_Order fromOrder, MFulfillment_ReturnRequest fromReturnRequest, IReadOnlyList <MFulfillment_ReturnRequestReason> fromReturnRequestReasons)
        {
            //var toReturnRequestItems = new List<ReturnRequestViewItemModel>();
            //foreach (var fromReturnRequestItem in fromReturnRequest.Items)
            //{
            //    var fromOrderItem = fromOrder.OrderItems.Where(r => r.OrderItem.OrderItemId == fromReturnRequestItem.OrderItemId).Single();
            //    if (fromOrderItem.OrderItem.CanReturn)
            //    {
            //        var toReturnRequestItem = new ReturnRequestViewItemModel()
            //        {
            //            OrderReturnRequestItemId = fromReturnRequestItem.OrderReturnRequestItemId,
            //            Quantity = fromReturnRequestItem.Quantity,
            //            OrderItem = ReturnRequestOrderModelFactory.CreateReturnRequestOrderItemModel(fromOrder.OrderItems.Where(r => r.OrderItem.OrderItemId == fromOrderItem.OrderItem.OrderItemId).Single())
            //        };
            //        toReturnRequestItems.Add(toReturnRequestItem);
            //    }
            //}

            //to.OrderReturnRequestId = fromReturnRequest.OrderReturnRequestId;
            //to.ReturnRequestNumber = fromReturnRequest.ReturnRequestNumber;
            //to.ReturnTypeCode = (int)fromReturnRequest.ReturnType;
            //to.ReturnTypeName = GetReturnTypeName(fromReturnRequest.ReturnType);
            //to.ReasonTypeCode = fromReturnRequest.ReasonTypeCode;
            //to.ReasonTypeName = fromReturnRequestReasons.Where(r => r.ReturnRequestReasonTypeCode == fromReturnRequest.ReasonTypeCode).Single().Name;
            //to.Notes = fromReturnRequest.Notes;
            //to.Items = toReturnRequestItems;
            //to.OrderId = fromOrder.MOrder.OrderId;
            //to.OrderNumber = fromOrder.MOrder.OrderNumber;
        }