Exemplo n.º 1
0
        public async Task <bool> VerifyPermissionsAsync(ILLDbContext context, Guid portfolioId)
        {
            //For tenancy, property must belong to portfolio
            var hasProperty = await(from propertyDetails in context.PropertyDetails.AsNoTracking()
                                    join portfolio in context.Portfolios on propertyDetails.PortfolioId equals portfolio.Id
                                    where portfolio.Id == portfolioId
                                    select 1)
                              .AnyAsync();

            if (!hasProperty)
            {
                return(false);
            }

            return(true);
        }
 public MustOwnPortfolioChecker(ILLDbContext context)
 {
     _context = context;
 }
Exemplo n.º 3
0
 public JourneysController(IJourneyDataProvider journeyDataProvider, ILLDbContext context)
 {
     _journeyDataProvider = journeyDataProvider;
     _context             = context;
 }
Exemplo n.º 4
0
 public UserRepository(ILLDbContext context, ApplicationUserManager userManager, ApplicationRoleManager roleManager)
 {
     _context     = context;
     _userManager = userManager;
     _roleManager = roleManager;
 }
Exemplo n.º 5
0
        public static async Task <bool> OwnsSupplierAsync(this Guid userId, Guid portfolioId, Guid supplierId, ILLDbContext context)
        {
            if (userId.IsDefault() || portfolioId.IsDefault() || supplierId.IsDefault() || context == null)
            {
                return(false);
            }

            return(await context.ApplicationUserPortfolios.AsNoTracking()
                   .Join(context.Suppliers, aup => aup.PortfolioId, supplier => supplier.PortfolioId, (portfolio, supplier) => new { ApplicationUserPortfolio = portfolio, Supplier = supplier })
                   .Where(c => c.ApplicationUserPortfolio.UserId == userId && c.ApplicationUserPortfolio.PortfolioId == portfolioId && c.Supplier.Id == supplierId)
                   .AnyAsync());
        }
 public MustOwnPropertyImageChecker(ILLDbContext context)
 {
     _context = context;
 }
 public PropertyDetailsController(IPropertyDataProvider dataAccessProvider, ILLDbContext context)
 {
     _propertyDataProvider = dataAccessProvider;
     _context = context;
 }
 public MustOwnSupplierChecker(ILLDbContext context)
 {
     _context = context;
 }
Exemplo n.º 9
0
        public static async Task <bool> OwnsPropertyDetailsAsync(this Guid userId, Guid propertyId, ILLDbContext context)
        {
            if (userId.IsDefault() || propertyId.IsDefault() || context == null)
            {
                return(false);
            }

            return(await context.PropertyDetails.Include(x => x.Portfolio.Users).AnyAsync(c => c.Portfolio.Users.Any(link => link.UserId == userId) && c.Id == propertyId));
        }
Exemplo n.º 10
0
        public static async Task <bool> OwnsPropertyImageAsync(this Guid userId, Guid propertyImageId, ILLDbContext context)
        {
            if (userId.IsDefault() || propertyImageId.IsDefault() || context == null)
            {
                return(false);
            }

            return(await context.ApplicationUserPortfolios.Include(x => x.Portfolio.Users)
                   .Where(aup => aup.Portfolio.Users.Any(link => link.UserId == userId))
                   .Join(context.PropertyDetails, aup => aup.PortfolioId, details => details.PortfolioId, (portfolio, details) => new { Portfolio = portfolio, PropertyDetails = details })
                   .Join(context.PropertyImages, arg => arg.PropertyDetails.Id, image => image.PropertyId, (details, image) => new { PropertyDetails = details, PropertyImage = image })
                   .AnyAsync(c => c.PropertyImage.Id == propertyImageId));
        }
Exemplo n.º 11
0
        public static async Task <bool> OwnsChecklistAsync(this Guid portfolioId, Guid checklistId, ILLDbContext context)
        {
            if (portfolioId.IsDefault() || checklistId.IsDefault() || context == null)
            {
                return(false);
            }

            return(await context.ChecklistInstances.Where(c => c.PortfolioId == portfolioId && c.Id == checklistId).AnyAsync());
        }
Exemplo n.º 12
0
 public MustOwnAccountChecker(ILLDbContext context)
 {
     _context = context;
 }
Exemplo n.º 13
0
        public static async Task <ApplicationUser> GetApplicationUserAsync(this ClaimsPrincipal claimsPrincipal, ILLDbContext context)
        {
            var userId = claimsPrincipal.GetUserId();

            if (userId != default(Guid))
            {
                return(await context.Users.FirstOrDefaultAsync(c => c.Id == userId));
            }

            throw new InvalidOperationException("Unable to determine User");
        }
Exemplo n.º 14
0
 public ConversationController(IConversationDataProvider conversationDataProvider, ILLDbContext context, NotificationsMessageHandler messageHandler)
 {
     _conversationDataProvider = conversationDataProvider;
     _context        = context;
     _messageHandler = messageHandler;
 }
Exemplo n.º 15
0
        public static async Task <bool> OwnsPortfolioAsync(this Guid userId, Guid portfolioId, ILLDbContext context)
        {
            if (userId.IsDefault() || portfolioId.IsDefault() || context == null)
            {
                return(false);
            }

            return(await context.ApplicationUserPortfolios.AnyAsync(c => c.UserId == userId && c.PortfolioId == portfolioId));
        }
Exemplo n.º 16
0
 public MustOwnPropertyDetailsChecker(ILLDbContext context)
 {
     _context = context;
 }
Exemplo n.º 17
0
        public static async Task <bool> OwnsAccountAsync(this Guid userId, Guid portfolioId, Guid accountId, ILLDbContext context)
        {
            if (userId.IsDefault() || portfolioId.IsDefault() || accountId.IsDefault() || context == null)
            {
                return(false);
            }

            return(await context.ApplicationUserPortfolios.AsNoTracking()
                   .Join(context.Accounts, aup => aup.PortfolioId, account => account.PortfolioId, (portfolio, account) => new { ApplicationUserPortfolio = portfolio, Account = account })
                   .Where(c => c.ApplicationUserPortfolio.UserId == userId && c.ApplicationUserPortfolio.PortfolioId == portfolioId && c.Account.Id == accountId)
                   .AnyAsync());
        }
Exemplo n.º 18
0
 public TransactionsController(ITransactionsDataProvider transactionsDataProvider, ILLDbContext context)
 {
     _transactionsDataProvider = transactionsDataProvider;
     _context = context;
 }
Exemplo n.º 19
0
        public static async Task <bool> OwnsInvoiceAsync(this Guid userId, Guid portfolioId, Guid invoiceId, ILLDbContext context)
        {
            if (userId.IsDefault() || portfolioId.IsDefault() || invoiceId.IsDefault() || context == null)
            {
                return(false);
            }

            return(await context.ApplicationUserPortfolios.AsNoTracking()
                   .Join(context.Invoices, aup => aup.PortfolioId, invoice => invoice.PortfolioId, (portfolio, invoice) => new { ApplicationUserPortfolio = portfolio, Invoice = invoice })
                   .Where(c => c.ApplicationUserPortfolio.UserId == userId && c.ApplicationUserPortfolio.PortfolioId == portfolioId && c.Invoice.Id == invoiceId)
                   .AnyAsync());
        }
Exemplo n.º 20
0
 public PropertyImageController(IPropertyImageDataProvider dataProvider, ILLDbContext context)
 {
     _dataProvider = dataProvider;
     _context      = context;
 }
Exemplo n.º 21
0
 public MustOwnInvoiceChecker(ILLDbContext context)
 {
     _context = context;
 }