private OutletDTO Map(tblCostCentre tbl)
        {
            var dto = new OutletDTO
                          {
                              MasterId = tbl.Id,
                              DateCreated = tbl.IM_DateCreated,
                              DateLastUpdated = tbl.IM_DateLastUpdated,
                              StatusId = tbl.IM_Status,
                              Name = tbl.Name,
                              CostCentreCode = tbl.Cost_Centre_Code,
                              ParentCostCentreId = tbl.ParentCostCentreId ?? Guid.Empty,
                              CostCentreTypeId = tbl.CostCentreType ?? 0,
                              RouteMasterId = tbl.RouteId ?? Guid.Empty,
                              OutletCategoryMasterId = tbl.Outlet_Category_Id ?? Guid.Empty,
                              OutletTypeMasterId = tbl.Outlet_Type_Id ?? Guid.Empty,
                              DiscountGroupMasterId = tbl.Outlet_DiscountGroupId ?? Guid.Empty,
                              OutletProductPricingTierMasterId = tbl.Tier_Id ?? Guid.Empty,
                              VatClassMasterId = tbl.VATClass_Id ?? Guid.Empty,
                              Latitude = tbl.StandardWH_Latitude,
                              Longitude = tbl.StandardWH_Longtitude,
                              IsApproved = tbl.IM_Status == (int)EntityStatus.Active,
                              ShippingAddresses = new List<ShipToAddressDTO>(),
                              SpecialPricingTierMasterId = tbl.SpecialPricingTierId ?? Guid.Empty,

                          };
            foreach (var item in tbl.tblShipToAddress.Where(n => n.IM_Status == (int)EntityStatus.Active))
            {
                var addressitem = new ShipToAddressDTO
                                      {
                                          OutletId = dto.MasterId,
                                          MasterId = item.Id,
                                          DateCreated = item.IM_DateCreated,
                                          DateLastUpdated = item.IM_DateLastUpdated,
                                          StatusId = item.IM_Status,
                                          Name = item.Name,
                                          Code = item.Code,
                                          Description = item.Description,
                                          PostalAddress = item.PostalAddress,
                                          PhysicalAddress = item.PhysicalAddress,
                                          Longitude = item.Longitude ?? 0,
                                          Latitude = item.Latitude ?? 0
                                      };
                dto.ShippingAddresses.Add(addressitem);
            }
            return dto;
        }
Ejemplo n.º 2
0
 public Outlet Map(OutletDTO dto)
 {
     if (dto == null) return null;
     var outlet = Mapper.Map<OutletDTO, Outlet>(dto);
     outlet.Route = _routeRepository.GetById(dto.RouteMasterId);
     outlet.OutletCategory = _outletCategoryRepository.GetById(dto.OutletCategoryMasterId);
     outlet.OutletType = _outletTypeRepository.GetById(dto.OutletTypeMasterId);
     //outlet.UsrSurveyor;
     //outlet.UsrSalesRep;
     //outlet.UsrASM;
     //outlet.ContactPerson;
     //outlet.PhoneNumber;
     outlet.OutletProductPricingTier = _pricingTierRepository.GetById(dto.OutletProductPricingTierMasterId);
     outlet.SpecialPricingTier = _pricingTierRepository.GetById(dto.SpecialPricingTierMasterId);
     outlet.VatClass = _vatClassRepository.GetById(dto.VatClassMasterId);
     outlet.DiscountGroup = _discountGroupRepository.GetById(dto.DiscountGroupMasterId);
     var shippingAddresses = dto.ShippingAddresses.Select(n => Map((ShipToAddressDTO) n)).ToList();
     shippingAddresses.ForEach(outlet.AddShipToAddress);
     return outlet;
 }