public AgentDto GetAgentByCardNo(Guid lockerBankId, string cardNumber)
        {
            AgentDbContext context = new AgentDbContext(_connectionStringFactory.GetConnectionString());

            var lockerBank = context.LockerBank.FirstOrDefault(lb => lb.LockerBankId == lockerBankId);

            var currentDate = _dateTime.GetCurrentDate();

            var agentDto = context.Agents
                   .Where(ag => ag.Properties.Any(prop => prop.BuildingPropertyId == lockerBank.BuildingPropertyId))
                   .Where(ag => ag.IsDisabled == false)
                   .Where(ag => ag.AgentCards.Any(agCard => agCard.AgentId == ag.AgentId &&
                                                  agCard.CardNumber.ToLower() == cardNumber.ToLower() && !agCard.IsLocked //&&
                                                  //agCard.EffectiveFrom > currentDate &&
                                                  //(agCard.EffectiveTo == null || !(currentDate > agCard.EffectiveTo.Value))
                                                  ))
                   .Select(agent => new AgentDto
                   {
                       AgentId = agent.AgentId,
                       EmailAddress = agent.EmailAddress,
                       FirstName = agent.FirstName,
                       LastName = agent.LastName,
                       MobileNumber = agent.MobileNumber,
                       OrganisationId = agent.OrganisationId
                   }).FirstOrDefault();

            return agentDto;
        }
示例#2
0
        public static void SeedHostDb(AgentDbContext context)
        {
            context.SuppressAutoSetTenantId = true;

            // Host seed
            new InitialHostDbBuilder(context).Create();

            // Default tenant seed (in host database).
            new DefaultTenantBuilder(context).Create();
            new TenantRoleAndUserBuilder(context, 1).Create();
        }
        public AgentDto GetAgentById(Guid lockerBankId, Guid agentId)
        {
            AgentDbContext context = new AgentDbContext(_connectionStringFactory.GetConnectionString());

            var lockerBank = context.LockerBank.FirstOrDefault(lb => lb.LockerBankId == lockerBankId);

            var agentDto = context.Agents
                   .Where(ag => ag.Properties.Any(prop => prop.BuildingPropertyId == lockerBank.BuildingPropertyId))
                   .Where(ag => ag.IsDisabled == false && ag.AgentId == agentId)
                   .Select(agent => new AgentDto
                   {
                       AgentId = agent.AgentId,
                       EmailAddress = agent.EmailAddress,
                       FirstName = agent.FirstName,
                       LastName = agent.LastName,
                       MobileNumber = agent.MobileNumber,
                       OrganisationId = agent.OrganisationId
                   }).FirstOrDefault();

            return agentDto;
        }
示例#4
0
 public TenantRoleAndUserBuilder(AgentDbContext context, int tenantId)
 {
     _context  = context;
     _tenantId = tenantId;
 }
        public bool IsAgentAuthorised(Guid lockerBankId, string agentUserName, string agentPassword)
        {
            AgentDbContext context = new AgentDbContext(_connectionStringFactory.GetConnectionString());

            var lockerBank = context.LockerBank.FirstOrDefault(lb => lb.LockerBankId == lockerBankId);

            var isAgentAuthorised = context.Agents
                   .Any(ag => ag.Properties.Any(prop => prop.BuildingPropertyId == lockerBank.BuildingPropertyId) &&
                              ag.IsDisabled == false && ag.Username.ToLower() == agentUserName.ToLower() && ag.SignInPin == agentPassword);

            return isAgentAuthorised;
        }
        public bool IsAgentAuthorised(Guid lockerBankId, string cardNumber)
        {
            AgentDbContext context = new AgentDbContext(_connectionStringFactory.GetConnectionString());

            var lockerBank = context.LockerBank.FirstOrDefault(lb => lb.LockerBankId == lockerBankId);

            var isAgentAuthorised = context.Agents
                   .Any(ag => ag.Properties.Any(prop => prop.BuildingPropertyId == lockerBank.BuildingPropertyId) &&
                              ag.IsDisabled == false &&
                               ag.AgentCards.Any(agCard => agCard.AgentId == ag.AgentId &&
                                                  agCard.CardNumber.ToLower() == cardNumber.ToLower() && !agCard.IsLocked &&
                                                  agCard.EffectiveFrom > _dateTime.GetCurrentDate() &&
                                                  (agCard.EffectiveTo == null || !(_dateTime.GetCurrentDate() > agCard.EffectiveTo.Value))));

            return isAgentAuthorised;
        }
 public DefaultTenantBuilder(AgentDbContext context)
 {
     _context = context;
 }
示例#8
0
 public HostRoleAndUserCreator(AgentDbContext context)
 {
     _context = context;
 }
示例#9
0
 public OrderRepository(AgentDbContext context)
 {
     dbContext = context;
 }
 public DefaultSettingsCreator(AgentDbContext context)
 {
     _context = context;
 }
示例#11
0
 public InitialHostDbBuilder(AgentDbContext context)
 {
     _context = context;
 }
 public DefaultEditionCreator(AgentDbContext context)
 {
     _context = context;
 }
 public WorkerRepository(AgentDbContext context)
 {
     dbContext = context;
 }
 public DefaultLanguagesCreator(AgentDbContext context)
 {
     _context = context;
 }