Beispiel #1
0
        /// <summary>
        /// The get one by user id.
        /// </summary>
        /// <param name="userId">
        /// The user id.
        /// </param>
        /// <returns>
        /// The <see cref="IFutureValue{CompanyLicense}"/>.
        /// </returns>
        public IFutureValue <CompanyLicense> GetOneByUserId(int userId)
        {
            User user      = null;
            var  queryOver =
                new DefaultQueryOver <CompanyLicense, int>().GetQueryOver()
                .JoinQueryOver(x => x.Company)
                .JoinQueryOver(c => c.Users, () => user)
                .Where(() => user.Id == userId);

            queryOver.TransformUsing(Transformers.DistinctRootEntity).Take(1);
            return(this.Repository.FindOne(queryOver));
        }
Beispiel #2
0
        /// <summary>
        /// The get one by company id.
        /// </summary>
        /// <param name="companyId">
        /// The company id.
        /// </param>
        /// <returns>
        /// The <see cref="IFutureValue{CompanyLicense}"/>.
        /// </returns>
        public IFutureValue <CompanyLicense> GetOneByCompanyId(int companyId)
        {
            var queryOver =
                new DefaultQueryOver <CompanyLicense, int>().GetQueryOver().Where(cl => cl.ExpiryDate > DateTime.UtcNow)
                .OrderBy(x => (int)x.LicenseStatus).Desc
                .OrderBy(x => x.DateCreated).Desc
                .JoinQueryOver(x => x.Company)
                .Where(c => c.Id == companyId);

            queryOver.TransformUsing(Transformers.DistinctRootEntity).Take(1);
            return(this.Repository.FindOne(queryOver));
        }