public bool BrokerHasReinsuranceBrokerGroup(int?brokerid) { var broker = _brokerRepository.Get(b => b.Brokerid == brokerid); bool result = (broker?.Parentgrouptypeid == CompanyCategory.ReinsuranceBrokerGroup); return(result); }
private UserEntityData GetByRole(RoleType role, long id) { switch (role) { case RoleType.Admin: return(_admins.GetAll().First(x => x.EntityId == id)); case RoleType.Manager: return(_managers.GetAll().First(x => x.EntityId == id)); case RoleType.Broker: var broker = _brokers.Get(id); return(new UserEntityData { Email = broker.Email, Language = broker.Language, Login = broker.Login, EntityId = broker.Id, Name = broker.Name, UserId = broker.UserId }); default: throw new ArgumentOutOfRangeException("role"); } }
public Broker[] GetBrokers() { return(ExecuteFaultHandledOperation(() => { IBrokerRepository brokerRepository = _DataRepositoryFactory.GetDataRepository <IBrokerRepository>(); Broker[] brokers = brokerRepository.Get().ToArray(); return brokers; })); }
private IEnumerable <RecipientData> GetRecipients(IEnumerable <RoleType> roles, EventDataForEntity data) { foreach (var role in roles) { switch (role) { case RoleType.Admin: { var recipients = _admins.GetAll() .Select(user => new RecipientData(user.Email, user.Language, RoleType.Admin)); foreach (var recipient in recipients) { yield return(recipient); } } break; case RoleType.Manager: { var recipients = _managers.GetAll() .Select(user => new RecipientData(user.Email, user.Language, RoleType.Manager)); foreach (var recipient in recipients) { yield return(recipient); } } break; case RoleType.Broker: var brokerId = _awbs.Get(data.EntityId).Single().BrokerId; if (brokerId.HasValue) { var broker = _brokers.Get(brokerId.Value); yield return(new RecipientData(broker.Email, broker.Language, role)); } break; case RoleType.Sender: foreach (var email in _awbs.GetSenderEmails(data.EntityId)) { yield return(new RecipientData(email.Email, email.Language, RoleType.Client)); } break; case RoleType.Client: foreach (var emailData in _awbs.GetClientEmails(data.EntityId)) { foreach (var email in EmailsHelper.SplitAndTrimEmails(emailData.Email)) { yield return(new RecipientData(email, emailData.Language, RoleType.Client)); } } break; case RoleType.Forwarder: foreach (var email in _awbs.GetForwarderEmails(data.EntityId)) { yield return(new RecipientData(email.Email, email.Language, RoleType.Client)); } break; case RoleType.Carrier: foreach (var email in _awbs.GetCarrierEmails(data.EntityId)) { yield return(new RecipientData(email.Email, email.Language, RoleType.Client)); } break; default: throw new InvalidOperationException("Unknown role " + role); } } }
public async Task Get_ShouldReturnNullIfBrokerDoesNotExists() { var result = await _brokerRepositoryMock.Get(9); Assert.IsNull(result); }
public BrokerData GetBroker(long brokerId) { return(_brokers.Get(brokerId)); }
/// <summary> /// Get a BrokerDTO by its Id /// </summary> /// <param name="id">Id of the broker to obtain</param> /// <returns>Task that returns a BrokerDTO entity</returns> public async Task <BrokerDTO> Get(int id) { var broker = await _repository.Get(id); return(Mapper.Map <Broker, BrokerDTO>(broker)); }
private IEnumerable <RecipientData> GetRecipients(ApplicationData application, IEnumerable <RoleType> roles) { foreach (var role in roles) { switch (role) { case RoleType.Admin: foreach ( var recipient in _admins.GetAll().Select(user => new RecipientData(user.Email, user.Language, RoleType.Admin))) { yield return(recipient); } break; case RoleType.Manager: foreach ( var recipient in _managers.GetAll().Select(user => new RecipientData(user.Email, user.Language, RoleType.Manager))) { yield return(recipient); } break; case RoleType.Sender: if (application.SenderId.HasValue) { var sender = _senders.Get(application.SenderId.Value); yield return(new RecipientData(sender.Email, sender.Language, role)); } break; case RoleType.Broker: if (application.AirWaybillId.HasValue) { var awb = _awbs.Get(application.AirWaybillId.Value).Single(); if (awb.BrokerId.HasValue) { var broker = _brokers.Get(awb.BrokerId.Value); yield return(new RecipientData(broker.Email, broker.Language, role)); } } break; case RoleType.Forwarder: var forwarder = _forwarders.Get(application.ForwarderId); yield return(new RecipientData(forwarder.Email, forwarder.Language, role)); break; case RoleType.Carrier: var carrier = _carriers.Get(application.CarrierId); yield return(new RecipientData(carrier.Email, carrier.Language, role)); break; case RoleType.Client: var client = _clients.Get(application.ClientId); foreach (var email in EmailsHelper.SplitAndTrimEmails(client.Emails)) { yield return(new RecipientData(email, client.Language, role)); } break; default: throw new InvalidOperationException("Unknown role " + role); } } }