Ejemplo n.º 1
0
        //public IEnumerable<ErrorDto> ListForTenant(int tenantId, int skip, int take, out int totalCount)
        //{
        //    using (var ctx = ((IEntityFrameworkObjectContext)contextFactory.GetContext()).ContextManager)
        //    {
        //        totalCount = (from error in ctx.ObjectContext.Error
        //                    where error.TenantId == tenantId
        //                    select error).ToList().Count();


        //        var result = (from error in ctx.ObjectContext.Error
        //                      where error.TenantId == tenantId
        //                      orderby error.UtcTime, error.Sequence
        //                      select new ErrorDto
        //                      {
        //                          Id = error.Id,
        //                          Host = error.Host,
        //                          Type = error.Type,
        //                          Source = error.Source,
        //                          Message = error.Message,
        //                          User = error.User,
        //                          StatusCode = error.StatusCode,

        //                          //TODO: figure out how to convert the time to the client's local time
        //                          UtcTime = error.UtcTime
        //                      });

        //        return result.Skip(skip).Take(take).ToList();
        //    }
        //}

        public IEnumerable <ErrorDto> ListForApplication(string application, int skip, int take, out int totalCount)
        {
            using (var ctx = ((IEntityFrameworkObjectContext)contextFactory.GetContext()).ContextManager)
            {
                totalCount = (from error in ctx.ObjectContext.Error
                              where error.Application == application
                              select error).ToList().Count();


                var result = (from error in ctx.ObjectContext.Error
                              where error.Application == application
                              orderby error.UtcTime, error.Sequence
                              select new ErrorDto
                {
                    Id = error.Id,
                    TenantId = error.TenantId,
                    Application = error.Application,
                    Host = error.Host,
                    Type = error.Type,
                    Source = error.Source,
                    Message = error.Message,
                    User = error.User,
                    StatusCode = error.StatusCode,

                    //TODO: figure out how to convert the time to the client's local time
                    UtcTime = error.UtcTime
                });

                return(result.Skip(skip).Take(take).ToList());
            }
        }
        public CategoryDto Fetch(Guid Id, int localeId)
        {
            using (var ctx = ((IEntityFrameworkObjectContext)contextFactory.GetContext()).ContextManager)
            {
                var result = (from category in ctx.ObjectContext.Category
                              join categoryLocale in ctx.ObjectContext.CategoryLocale
                              on category.Id equals categoryLocale.CategoryId
                              join page in ctx.ObjectContext.Page
                              on category.Id equals page.ContentId
                              join pageLocale in ctx.ObjectContext.PageLocale
                              on page.Id equals pageLocale.PageId

                              where category.Id == Id
                              where categoryLocale.LocaleId == localeId
                              where pageLocale.LocaleId == localeId
                              where page.ContentType == 2 //category type

                              select new CategoryDto
                {
                    Id = category.Id,
                    Title = pageLocale.Title,
                    Description = categoryLocale.Description,
                    MetaKeywords = pageLocale.MetaKeywords,
                    MetaDescription = pageLocale.MetaDescription
                }).FirstOrDefault();

                if (result == null)
                {
                    throw new DataNotFoundException("Category");
                }
                return(result);
            }
        }
        public IEnumerable <AssemblyTypeLocaleDto> List(int tenantId, int localeId, int hashCode, string typeName)
        {
            using (var ctx = ((IEntityFrameworkObjectContext)contextFactory.GetContext()).ContextManager)
            {
                var result = (from assemblyTypeText in ctx.ObjectContext.AssemblyTypeText
                              join assemblyType in ctx.ObjectContext.AssemblyType
                              on assemblyTypeText.AssemblyTypeId equals assemblyType.Id
                              join assemblyTypeTextLocale in ctx.ObjectContext.AssemblyTypeTextLocale
                              on assemblyTypeText.Id equals assemblyTypeTextLocale.AssemblyTypeTextId
                              join tenant in ctx.ObjectContext.Tenant
                              on assemblyType.TenantId equals tenant.Id

                              where assemblyType.TenantId == tenantId
                              where assemblyType.TypeNameHashCode == hashCode && assemblyType.TypeName == typeName
                              where assemblyTypeTextLocale.LocaleId == localeId || assemblyTypeTextLocale.LocaleId == tenant.DefaultLocaleId
                              select new AssemblyTypeLocaleDto
                {
                    TextName = assemblyTypeText.TextName,
                    Value = assemblyTypeTextLocale.Value,
                    LocaleId = assemblyTypeTextLocale.LocaleId
                });

                return(result.ToList());
            }
        }
Ejemplo n.º 4
0
        public IList <ParentUrlPageDto> ListForParentUrl(int tenantId)
        {
            using (var ctx = ((IEntityFrameworkObjectContext)contextFactory.GetContext()).ContextManager)
            {
                var result = (from pageLocale in ctx.ObjectContext.PageLocale
                              join page in ctx.ObjectContext.Page
                              on pageLocale.PageId equals page.Id
                              where page.TenantId == tenantId
                              select new ParentUrlPageDto
                {
                    Id = page.Id,
                    ParentId = page.ParentId == null ? Guid.Empty : (Guid)page.ParentId,
                    TenantId = tenantId,
                    LocaleId = pageLocale.LocaleId,
                    ContentType = page.ContentType,
                    ContentId = page.ContentId,
                    Url = pageLocale.Url,
                    IsUrlAbsolute = pageLocale.IsUrlAbsolute
                });

                return(result.ToList());
            }
        }
        public IList <CategoryProductDto> ListForCategory(Guid categoryId, int localeId)
        {
            using (var ctx = ((IEntityFrameworkObjectContext)contextFactory.GetContext()).ContextManager)
            {
                var result = (from categoryXProduct in ctx.ObjectContext.CategoryXProduct
                              join product in ctx.ObjectContext.Product
                              on categoryXProduct.ProductId equals product.Id
                              join productXTenantXlocale in ctx.ObjectContext.ProductXTenantXLocale
                              on product.Id equals productXTenantXlocale.ProductId

                              where categoryXProduct.CategoryId == categoryId
                              where productXTenantXlocale.LocaleId == localeId
                              select new CategoryProductDto
                {
                    CategoryXProductId = categoryXProduct.Id,
                    Name = productXTenantXlocale.Name,
                    SKU = product.SKU,
                    ImageUrl = product.ImageUrl,
                    Price = product.Price
                });

                return(result.ToList());
            }
        }
Ejemplo n.º 6
0
        public TenantDto Fetch(string host)
        {
            using (var ctx = ((IEntityFrameworkObjectContext)contextFactory.GetContext()).ContextManager)
            {
                var tenant = (from t in ctx.ObjectContext.Tenant
                              where t.Host == host
                              select t).FirstOrDefault();

                var result = Mapper.Map <Tenant, TenantDto>(tenant);


                //if (result == null)
                //    throw new DataNotFoundException("Store");
                return(result);
            }
        }
Ejemplo n.º 7
0
        public IEnumerable <ViewLocaleDto> List(int tenantId, int localeId, int hashCode, string virtualPath)
        {
            using (var ctx = ((IEntityFrameworkObjectContext)contextFactory.GetContext()).ContextManager)
            {
                //var result = (from view in ctx.ObjectContext.View

                //              join tenant in ctx.ObjectContext.Tenant
                //                  on view.TenantId equals tenant.Id

                //              // Left Join
                //              join viewLocale in ctx.ObjectContext.ViewLocale
                //                on view.Id equals viewLocale.ViewId into x
                //              from locale in x.DefaultIfEmpty()

                //              // Left Join
                //              join defaultViewLocale in ctx.ObjectContext.ViewLocale
                //                  on view.Id equals defaultViewLocale.ViewId into y
                //              from defaultLocale in y.DefaultIfEmpty()

                //              where view.TenantId == tenantId
                //              where locale.LocaleId == localeId
                //              where defaultLocale != null ? defaultLocale.LocaleId == tenant.DefaultLocaleId : true
                //              select new ViewLocaleDto
                //              {
                //                  TextName = view.TextName,
                //                  Value = locale == null ? viewLocale.Value :
                //              });

                //var result = (from viewLocale in ctx.ObjectContext.ViewLocale
                //                 join view in ctx.ObjectContext.View
                //                    on viewLocale.ViewId equals view.Id
                //              join tenant in ctx.ObjectContext.Tenant
                //                  on view.TenantId equals tenant.Id

                //              where view.TenantId == tenantId
                //              where view.HashCode == hashCode && view.VirtualPath == virtualPath
                //              where viewLocale.LocaleId == localeId || viewLocale.LocaleId == tenant.DefaultLocaleId
                //              select new ViewLocaleDto
                //              {
                //                  TextName = view.TextName,
                //                  Value = viewLocale.Value,
                //                  LocaleId = viewLocale.LocaleId
                //              });

                //return result.ToList();


                var result = (from viewText in ctx.ObjectContext.ViewText
                              join view in ctx.ObjectContext.View
                              on viewText.ViewId equals view.Id
                              join viewTextLocale in ctx.ObjectContext.ViewTextLocale
                              on viewText.Id equals viewTextLocale.ViewTextId
                              join tenant in ctx.ObjectContext.Tenant
                              on view.TenantId equals tenant.Id

                              where view.TenantId == tenantId
                              where view.VirtualPathHashCode == hashCode && view.VirtualPath == virtualPath
                              where viewTextLocale.LocaleId == localeId || viewTextLocale.LocaleId == tenant.DefaultLocaleId
                              select new ViewLocaleDto
                {
                    TextName = viewText.TextName,
                    Value = viewTextLocale.Value,
                    LocaleId = viewTextLocale.LocaleId
                });

                return(result.ToList());
            }
        }