private async Task<GRNDto.GRNLineItem> MapLineItem(WarehouseGRNListItem item)
        {
            using (var c = NestedContainer)
            {
                var weight = (float) item.CommodityWeight;
                RequestResult<CommodityDto> commodityId =
                    await Using<IEagcServiceProxy>(c).GetCommodityByExternalKey(item.CommodityId);
                if (commodityId == null)
                {
                    MessageBox.Show("Commodity Not Found!", "Trading Platform", MessageBoxButton.OKCancel,
                        MessageBoxImage.Error);

                }
                else
                {
                    CommodityId = commodityId;
                    var grnLineItem = new GRNDto.GRNLineItem(commodityId.Result.Id, item.Commodity, item.CommodityGrade,
                        weight);
                    return grnLineItem;
                }
                return null;
            }
        }
        private WarehouseGRNListItem Map(CommodityWarehouseStorageNote commodityWarehouseStorageNote)
        {
            var item = new WarehouseGRNListItem();

            item.DocumentId = commodityWarehouseStorageNote.Id;

            var commodityWarehouseStorageLineItem = commodityWarehouseStorageNote.LineItems.FirstOrDefault();
            if (commodityWarehouseStorageLineItem != null)
            {
                item.Commodity = commodityWarehouseStorageLineItem.Commodity.Name;
                item.CommodityGrade = commodityWarehouseStorageLineItem.CommodityGrade.Name;

                item.CommodityId = commodityWarehouseStorageLineItem.Commodity.Id.ToString();
                item.CommodityGradeId = commodityWarehouseStorageLineItem.CommodityGrade.Id.ToString();

                item.InitialWeight = commodityWarehouseStorageLineItem.Weight;
                item.FinalWeight = commodityWarehouseStorageLineItem.FinalWeight;
                item.CommodityWeight = item.InitialWeight - item.FinalWeight;
            }
            item.IsSelected = false;
            item.CommodityOwner = Using<ICommodityOwnerRepository>(NestedContainer)
                                .GetById(commodityWarehouseStorageNote.CommodityOwnerId).FullName;
            item.CommodityOwnerName = Using<ICommodityOwnerRepository>(NestedContainer)
                                  .GetById(commodityWarehouseStorageNote.CommodityOwnerId);

            //Check if farmer exist in EAGC
            SelectedCommodityOwner = item.CommodityOwnerName;

            return item;
        }
 private GRNDto MapGrnDto(WarehouseGRNListItem item, IEnumerable<GRNDto.GRNLineItem> grnLineItems)
 {
     var receiptNo = GetDocumentReference("WarehouseReceipt");
     var grnDto = new GRNDto(receiptNo, DateTime.Now, grnLineItems);
     return grnDto;
 }