Exemplo n.º 1
0
        public IActionResult Index()
        {
            var list = _partnerRepository.GetAll()
                       .Where(p => p.IsAproved)
                       .Select(p => new IndexViewModel
            {
                Id             = p.Id,
                IsStarAlliance = p.IsStarAlliance,
                CreationDate   = p.CreationDate,
                Name           = p.Name,
                IsAproved      = p.IsAproved
            });

            return(View(list));
        }
        public Task <bool> Handle(CreatePartnerCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            var partner = new Partner(message.Id, message.TradingName, message.OwnerName, message.Document, message.CoverageArea, message.Address, message.DeserializedCoverageArea, message.DeserializedAddress);

            if (_partnerRepository.GetById(partner.Id) != null)
            {
                Bus.RaiseEvent(new DomainNotification(message.MessageType, "The partner id has already been taken."));
                return(Task.FromResult(false));
            }
            else if (_partnerRepository.GetAll().Where(x => x.Document == partner.Document).Count() > 0)
            {
                Bus.RaiseEvent(new DomainNotification(message.MessageType, "The document has already been taken."));
                return(Task.FromResult(false));
            }

            _partnerRepository.Add(partner);

            if (Commit())
            {
                Bus.RaiseEvent(new PartnerCreatedEvent(partner.Id, partner.TradingName, partner.OwnerName, partner.Document, partner.CoverageArea, partner.Address, message.DeserializedCoverageArea, message.DeserializedAddress));
            }

            return(Task.FromResult(true));
        }
Exemplo n.º 3
0
        public IEnumerable <Partner> GetPartners()
        {
            IEnumerable <Partner> par = partner_repo.GetAll();

            par = par.OrderByDescending(s => s.PartnerId);
            return(par);
        }
        public IList <MusicContract> Get(string partnerName, DateTime effectiveDate)
        {
            var partner = _partnerRepository.GetAll().FirstOrDefault(p => p.Name == partnerName);

            if (partner == null)
            {
                return(new List <MusicContract>());
            }

            var partnerContracts = _musicContractRepository
                                   .GetAll()
                                   .Where(mc => mc.DistributionChannels.Any(dc => partner.SupportedDistributionChannels.Contains(dc)))
                                   .Where(mc => !mc.StartDate.HasValue || mc.StartDate.Value <= effectiveDate)
                                   .Where(mc => !mc.EndDate.HasValue || mc.EndDate.Value >= effectiveDate)
                                   .ToList();

            foreach (var partnerContract in partnerContracts)
            {
                partnerContract.DistributionChannels = partnerContract.DistributionChannels.Where(dc => partner.SupportedDistributionChannels.Contains(dc)).ToList();
            }

            return(partnerContracts);
        }
Exemplo n.º 5
0
 // GET: Partners
 public async Task <IActionResult> Index()
 {
     return(View(await _partnerRepository.GetAll().ToListAsync()));
 }
 public IEnumerable <Partner> GetPartners()
 {
     return(partnersRepository.GetAll());
 }
Exemplo n.º 7
0
 public IEnumerable <PartnerViewModel> GetAll()
 {
     return(_mapper.Map <IEnumerable <PartnerViewModel> >(_partnerRepository.GetAll()));
 }
Exemplo n.º 8
0
 public IList <Partner> GetAllPartners()
 {
     return(PartnerRepository.GetAll());
 }