Exemplo n.º 1
0
      public Distributor MapDistributor(tblCostCentre tblCC)
      {
          if (tblCC == null) return null;
          var distributor = new Distributor(tblCC.Id) {CostCentreType = CostCentreType.Distributor};
          if (tblCC.tblRegion != null)
              distributor.Region = tblCC.tblRegion.Map();
          if (tblCC.Tier_Id != null)
              distributor.ProductPricingTier =
                  _ctx.tblPricingTier.FirstOrDefault(n => n.id == tblCC.Tier_Id).Map();
          distributor.CostCentreCode = tblCC.Cost_Centre_Code;
          if (tblCC.PaybillNumber != null)
              distributor.PaybillNumber = tblCC.PaybillNumber;
          if (tblCC.MerchantNumber != null)
              distributor.MerchantNumber = tblCC.MerchantNumber;

          return distributor;
      }
Exemplo n.º 2
0
        private ReceiptHeaderInfo FormatHeader(Contact contact, string companyName,Distributor distributr )
        {
            if (contact == null)
                return new ReceiptHeaderInfo()
                           {
                               CompanyName =string.IsNullOrEmpty(companyName)?"Company Name":companyName,
                               PinVatNo =
                               string.Format("VAT No.:{0}  PIN No.:{1}",
                                             distributr != null ? distributr.VatRegistrationNo : "",
                                             distributr != null ? distributr.PIN : "")
                           };

            var physical=string.IsNullOrEmpty(contact.PhysicalAddress)
                                          ? contact.City
                                          : contact.City + " ,"
                                            + contact.PhysicalAddress;
            return new ReceiptHeaderInfo()
                       {
                           CompanyName = string.IsNullOrEmpty(companyName)?"Company Name":companyName,
                           WebSite = "Website:_____________",
                           Email =string.Format("Email:{0}",contact.Email),
                           Address = string.Format("P.O Box: {0},{1}", contact.PostalAddress ?? "_ _ _ _", physical),
                           PinVatNo =
                               string.Format("VAT No.:{0}  PIN No.:{1}",
                                             distributr != null ? distributr.VatRegistrationNo : "",
                                             distributr != null ? distributr.PIN : ""),
                           TelNo =
                               string.Format("Fixed No.:{0},Cell.:{1},Fax:{2}", contact.BusinessPhone,
                                             contact.MobilePhone, contact.Fax)

                       };
        }
Exemplo n.º 3
0
 public DistributorDTO Map(Distributor distributor)
 {
     if (distributor == null) return null;
     DistributorDTO dto = Mapper.Map<Distributor, DistributorDTO>(distributor);
     dto.ASMDTO = Map(distributor.ASM);
     dto.SalesRepDTO = Map(distributor.SalesRep);
     dto.SurveyorDTO = Map(distributor.Surveyor);
     return dto;
 }
 private void AssertDistributor(Distributor competitor, Distributor savedCompetitor)
 {
     Assert.AreEqual(competitor.Name,savedCompetitor.Name);
     Assert.AreEqual(competitor._Status,EntityStatus.Active);
 }
Exemplo n.º 5
0
        public void LoadSalesMen()
        {
            using (var container = NestedContainer)
            {

                var _costCentreService = Using<ICostCentreRepository>(container);
                
                SelectedSaleMan = null;
                SalesMen.Clear();
                var salesman =
                    new Distributor(Guid.Empty)
                        {
                            Name =
                                "--Please select " + GetLocalText("sl.viewInventoryTransfers.salesmen_lbl") +
                                "--"
                        } as Warehouse; //a salesman
                SalesMen.Add(salesman);
                _costCentreService.GetAll().OfType<DistributorSalesman>()
                    .OrderBy(n => n.Name)
                    .ToList()
                    .ForEach(n => SalesMen.Add(n));
                SelectedSaleMan = salesman;
            }
        }
Exemplo n.º 6
0
 public DistributorDTO Map(Distributor distributor)
 {
     if (distributor == null) return null;
     return Mapper.Map<Distributor, DistributorDTO>(distributor);
 }
      private IEnumerable<DistributorSalesman> ConstructDomainEntities(IEnumerable<DistributorSalesmanImport> entities)
      {
          
          var newSalesmen = new List<DistributorSalesman>();

          var defaultDistributr =
              _costCentreRepository.GetByCode("87878", CostCentreType.Distributor) as Distributor;
                               
          foreach (var importentity in entities)
          {
              var domainEntity = _costCentreRepository.GetByCode(importentity.SalesmanCode,CostCentreType.DistributorSalesman, true) as DistributorSalesman;
              distributor = defaultDistributr;
              if(!string.IsNullOrEmpty(importentity.DistributorCode))
                  distributor = _costCentreRepository.GetByCode(importentity.DistributorCode, CostCentreType.Distributor, true) as Distributor ?? defaultDistributr;
              if (distributor == null) throw new ArgumentNullException("distributor");
              if (domainEntity == null)
              {
                  domainEntity = _costCentreFactory.CreateCostCentre(Guid.NewGuid(),
                                                                     CostCentreType.DistributorSalesman, distributor) as
                                 DistributorSalesman;
              }
              domainEntity.Name = importentity.Name;
              domainEntity.CostCentreCode = importentity.SalesmanCode;
              domainEntity.CostCentreType = CostCentreType.DistributorSalesman;
              newSalesmen.Add(domainEntity);
          }
          return newSalesmen.ToList();
      }
        DistributorViewModel Map(Distributor distributor)
        {
            DistributorViewModel distributorViewModel = new DistributorViewModel();
            distributorViewModel.Id = distributor.Id;
            distributorViewModel.Name = distributor.Name;
            distributorViewModel.Owner = distributor.Owner;
            if (distributor.Region != null)
            {
                distributorViewModel.RegionId = distributor.Region.Id;
                distributorViewModel.RegionName = distributor.Region.Name;
            }


            if (distributor.SalesRep != null)
            {
                distributorViewModel.SalesRepName =_userRepository.GetById(distributor.SalesRep.Id).Username;
            }
            if (distributor.Surveyor != null)
            {
                distributorViewModel.SurveyorName =_userRepository.GetById(distributor.Surveyor.Id).Username;
            }
            if (distributor.ASM != null)
            {
                distributorViewModel.ASMName =_userRepository.GetById( distributor.ASM.Id).Username;
            }

            distributorViewModel.RegionId = distributor.Region == null ? Guid.Empty: distributor.Region.Id;
            distributorViewModel.PricingTierId = distributor.ProductPricingTier == null ? Guid.Empty : distributor.ProductPricingTier.Id;
            distributorViewModel.Region =distributor.Region==null ? "": _regionrepository.GetById(distributor.Region.Id).Name;
            distributorViewModel.AccountNo = distributor.AccountNo;
            distributorViewModel.VatRegistrationNo = distributor.VatRegistrationNo;
            distributorViewModel.PIN = distributor.PIN;
            distributorViewModel.CostCentreCode = distributor.CostCentreCode;
            distributorViewModel.DateCreated = distributor._DateCreated;
            distributorViewModel.PayBillNumber = distributor.PaybillNumber;
            distributorViewModel.MerchantNumber = distributor.MerchantNumber;
            distributorViewModel.ASM = distributor.ASM == null ? Guid.Empty : distributor.ASM.Id;
            distributorViewModel.SalesRep = distributor.SalesRep == null ? Guid.Empty : distributor.SalesRep.Id;
            distributorViewModel.Surveyor = distributor.Surveyor == null ? Guid.Empty : distributor.Surveyor.Id;
            if (distributor.Id == Guid.Empty)
                distributorViewModel.IsActive = true;
            else
                distributorViewModel.IsActive = distributor._Status == EntityStatus.Active ? true : false;

            distributorViewModel.CanEditRegion = _masterDataUsage.CanEditHubOrDistributrRegion(distributor);

            return distributorViewModel;


        }