//private void CopyReturnRequestEditModel(ReturnRequestEditModel to, UOrder_Order fromOrder, MFulfillment_ReturnRequest fromReturnRequest, IReadOnlyList<MFulfillment_ReturnRequestReason> fromReturnRequestReasons)
        //{
        //    var toReturnRequestItems = new List<ReturnRequestEditItemModel>();
        //    foreach (var fromReturnRequestItem in fromReturnRequest.ReturnRequestItems)
        //    {
        //        var fromOrderItemId = ParseOrderItemId.FromFulfillableItemReference(fromReturnRequestItem.FulfillableItemReference);
        //        var fromOrderItem = fromOrder.MOrder.OrderItems.Where(r => r.OrderItemId == fromOrderItemId).Single();
        //        if (fromOrderItem.CanReturn)
        //        {
        //            var toReturnRequestItem = new ReturnRequestEditItemModel()
        //            {
        //                OrderReturnRequestItemId = fromReturnRequestItem.ReturnRequestItemId,
        //                Quantity = fromReturnRequestItem.Quantity,
        //                MaximumQuantity = fromOrderItem.FulfillmentCompleteQuantity,
        //                OrderItem = ReturnRequestOrderModelFactory.CreateReturnRequestOrderItemModel(fromOrder.MOrder.OrderItems.Where(r => r.OrderItemId == fromOrderItem.OrderItemId).Single())
        //            };
        //            toReturnRequestItems.Add(toReturnRequestItem);
        //        }
        //    }

        //    to.OrderReturnRequestId = fromReturnRequest.ReturnRequestId;
        //    to.ReturnTypeCode = fromReturnRequest.ReturnRequestType;
        //    to.ReturnTypeName = fromReturnRequest.ReturnRequestTypeCode;
        //    //to.ReasonTypeCode = fromReturnRequest.re;
        //    //to.ReasonTypeName = fromReturnRequestReasons.Where(r => r.ReturnRequestReasonTypeCode == fromReturnRequest.ReasonTypeCode).SingleOrDefault()?.Name;
        //    to.ReasonTypes = CreateReasonTypes(fromReturnRequestReasons);
        //    //to.Notes = fromReturnRequest.;
        //    to.Items = toReturnRequestItems;
        //    to.OrderId = fromOrder.MOrder.OrderId;
        //    to.OrderNumber = fromOrder.MOrder.OrderNumber;
        //}

        private void CopyReturnRequestEditModel(ReturnRequestEditModel to, UOrder_Order fromOrder, IReadOnlyList <MFulfillment_ReturnRequestReason> fromReturnRequestReasons)
        {
            var toReturnRequestItems = new List <ReturnRequestEditItemModel>();

            foreach (var fromOrderItem in fromOrder.MOrder.OrderItems)
            {
                if (fromOrderItem.CanReturn)
                {
                    var toReturnRequestItem = new ReturnRequestEditItemModel()
                    {
                        OrderReturnRequestItemId = null,
                        Quantity        = 0,
                        MaximumQuantity = fromOrderItem.NetQuantity,
                        OrderItem       = ReturnRequestOrderModelFactory.CreateReturnRequestOrderItemModel(fromOrder.MOrder.OrderItems.Where(r => r.OrderItemId == fromOrderItem.OrderItemId).Single())
                    };
                    toReturnRequestItems.Add(toReturnRequestItem);
                }
            }

            to.OrderReturnRequestId = null;
            //to.ReturnTypeCode = 0;
            to.ReturnTypeName = null;
            to.ReasonTypeCode = null;
            to.ReasonTypeName = null;
            to.ReasonTypes    = CreateReasonTypes(fromReturnRequestReasons);
            to.Notes          = null;
            to.Items          = toReturnRequestItems;
            to.OrderId        = fromOrder.MOrder.OrderId;
            to.OrderNumber    = fromOrder.MOrder.OrderNumber;
        }
        public ReturnRequestEditModel CreateReturnRequestEditModel(UOrder_Order fromOrder, MFulfillment_ReturnRequest fromReturnRequest, IReadOnlyList <MFulfillment_ReturnRequestReason> fromReturnRequestReasons)
        {
            var to = new ReturnRequestEditModel();

            if (fromReturnRequest != null)
            {
                //CopyReturnRequestEditModel(to, fromOrder, fromReturnRequest, fromReturnRequestReasons);
            }
            else
            {
                CopyReturnRequestEditModel(to, fromOrder, fromReturnRequestReasons);
            }
            return(to);
        }