Exemple #1
0
        public static RFSViewModel MapToViewModel(TblRFSHeader objectToBeMapped, RFSViewModel objectToBeFilled)
        {
            if (objectToBeFilled == null)
            {
                objectToBeFilled = new RFSViewModel();
            }
            objectToBeFilled.TransID    = objectToBeMapped.TransID;
            objectToBeFilled.BrandCode  = objectToBeMapped.BrandCode;
            objectToBeFilled.BrandProp  = objectToBeFilled.Brands.FirstOrDefault(x => x.Brand_Code == objectToBeFilled.BrandCode);
            objectToBeFilled.SeasonCode = objectToBeMapped.SeasonCode;
            objectToBeFilled.SeasonProp = objectToBeFilled.Seasons.FirstOrDefault(x => x.Code == objectToBeFilled.SeasonCode);

            objectToBeFilled.SupplierID   = objectToBeMapped.SupplierCode;
            objectToBeFilled.SupplierProp = objectToBeFilled.Vendors.FirstOrDefault(x => x.vendor_code == objectToBeFilled.SupplierID);
            objectToBeFilled.DocNum       = objectToBeMapped.DocNumber;

            objectToBeFilled.ObjStatus = new ObjectStatus();

            foreach (var item in objectToBeMapped.TblRFSDetails)
            {
                objectToBeFilled.RFQHeaderList.Add(new RFSSubHeader(objectToBeFilled.RFQItems, objectToBeFilled.RFQServices));
                var temp2 = objectToBeFilled.RFQHeaderList[objectToBeFilled.RFQHeaderList.Count - 1];
                temp2.HeaderImage       = item.Image;
                temp2.Desc              = item.Description;
                temp2.MainHeaderTransID = objectToBeFilled.TransID;
                temp2.Style             = item.StyleCode;
                temp2.ColorCode         = item.ColorCode;
                temp2.SizeCode          = item.SizeCode;
                temp2.ObjStatus         = new ObjectStatus {
                    IsNew = false, IsSavedDBItem = true, IsEmpty = false
                };

                foreach (var itemTemp in item.TblRFSDetailItems.Select(iItems => new RFSHeaderItem(temp2.RFQItems)
                {
                    Description = iItems.Description,
                    Image = iItems.Image,
                    Iserial = iItems.Iserial,
                    ItemCode = iItems.ItemCode,
                    ParentID = temp2.SubHeaderSerial,
                    ItemGroup = iItems.Source,
                    Batch = iItems.Batch,
                    Config = iItems.Configuration,
                    Size = iItems.Size,
                    Name = iItems.Name
                }))
                {
                    itemTemp.SelectedRFQItem = new ItemsDto
                    {
                        Code      = itemTemp.ItemCode,
                        Desc      = itemTemp.Description,
                        Image     = itemTemp.Image,
                        ItemGroup = itemTemp.ItemGroup,
                        Size      = itemTemp.Size,
                        Config    = itemTemp.Config,
                        Batch     = itemTemp.Batch,
                        Name      = itemTemp.Name
                    };
                    itemTemp.ObjStatus = new ObjectStatus {
                        IsNew = false, IsSavedDBItem = true, IsEmpty = false
                    };

                    temp2.HeaderItems.Add(itemTemp);
                }

                foreach (var servtemp in item.TblRFSDetailServices.Select(sItem => new RFSHeaderServices(temp2.RFQServices)
                {
                    Image = sItem.Image,
                    Iserial = sItem.Iserial,
                    Notes = sItem.Notes,
                    ServiceCode = sItem.ServiceCode,
                    ParentID = temp2.SubHeaderSerial
                }))
                {
                    servtemp.SelectedRFQService = servtemp.RFQServices.FirstOrDefault(x => x.Code == servtemp.ServiceCode);
                    servtemp.ObjStatus          = new ObjectStatus {
                        IsNew = false, IsSavedDBItem = true, IsEmpty = false
                    };

                    temp2.HeaderServices.Add(servtemp);
                }
            }
            objectToBeFilled.FormMode                = ObjectMode.LoadedFromDb;
            objectToBeFilled.ObjStatus.IsNew         = false;
            objectToBeFilled.ObjStatus.IsSavedDBItem = true;
            return(objectToBeFilled);
        }
Exemple #2
0
        public static TblRFSHeader MapToModel(RFSViewModel objectToBemapped, bool isFullObjectMapper)
        {
            var temp = new TblRFSHeader
            {
                BrandCode    = objectToBemapped.BrandCode,
                SeasonCode   = objectToBemapped.SeasonCode,
                SupplierCode = objectToBemapped.SupplierID
            };

            if (objectToBemapped.TransID != null)
            {
                temp.TransID = (int)objectToBemapped.TransID;
            }
            temp.DocNumber     = objectToBemapped.DocNum ?? " ";
            temp.TblRFSDetails = new ObservableCollection <TblRFSDetail>();
            foreach (var item in objectToBemapped.RFQHeaderList)
            {
                var stemp = new TblRFSDetail
                {
                    Description = item.Desc,
                    Image       = item.HeaderImage
                };
                if (item.MainHeaderTransID != null)
                {
                    stemp.tblRFSHeader = item.MainHeaderTransID;
                }
                stemp.StyleCode = item.Style;
                stemp.ColorCode = item.ColorCode;
                stemp.SizeCode  = item.SizeCode;
                if (item.SubHeaderSerial != null)
                {
                    stemp.Iserial = (int)item.SubHeaderSerial;
                }
                stemp.TblRFSDetailServices = new ObservableCollection <TblRFSDetailService>();
                foreach (var sItem in item.HeaderServices)
                {
                    var hsTemp = new TblRFSDetailService {
                        Image = sItem.Image
                    };

                    if (sItem.Iserial != null)
                    {
                        hsTemp.Iserial = (int)sItem.Iserial;
                    }

                    hsTemp.Notes = sItem.Notes;
                    if (sItem.ServiceCode != null)
                    {
                        hsTemp.ServiceCode = sItem.ServiceCode;
                    }

                    if (sItem.ParentID != null)
                    {
                        hsTemp.Iserial = (int)sItem.ParentID;
                    }

                    stemp.TblRFSDetailServices.Add(hsTemp);
                }
                stemp.TblRFSDetailItems = new ObservableCollection <TblRFSDetailItem>();
                foreach (var iItems in item.HeaderItems)
                {
                    var iTemp = new TblRFSDetailItem
                    {
                        ItemCode      = iItems.SelectedRFQItem.Code,
                        Description   = iItems.Description,
                        Image         = iItems.Image,
                        Size          = iItems.SelectedRFQItem.Size,
                        Configuration = iItems.SelectedRFQItem.Config,
                        Batch         = iItems.SelectedRFQItem.Batch,
                        Name          = iItems.SelectedRFQItem.Name,
                        Source        = iItems.SelectedRFQItem.ItemGroup
                    };
                    if (iItems.Iserial != null)
                    {
                        iTemp.Iserial = (int)iItems.Iserial;
                    }

                    iTemp.ItemCode = iItems.ItemCode;
                    if (iItems.ParentID != null)
                    {
                        iTemp.tblRFSDetail = iItems.ParentID;
                    }

                    stemp.TblRFSDetailItems.Add(iTemp);
                }

                temp.TblRFSDetails.Add(stemp);
            }
            return(temp);
        }