public PagedResult <Contracts.ProcessCategory.ProcessCategory> Get(PagedQuery pagedQuery)
 {
     using (var db = new RAAPEntities(GetConnectionString()))
     {
         var totalItems = db.ProcessCategories.Count();
         try
         {
             return(new PagedResult <Contracts.ProcessCategory.ProcessCategory>()
             {
                 CurrentPage = pagedQuery.Page,
                 TotalItems = totalItems,
                 TotalPages = pagedQuery.CalculatePages(totalItems),
                 Items =
                     db.ProcessCategories.AsQueryable()
                     .OrderByDirection(LinqHelper.OrderByDataContract <ProcessCategory>(pagedQuery.OrderByKey),
                                       pagedQuery.IsDescending)
                     .Skip(pagedQuery.ItemsToSkip)
                     .Take(pagedQuery.PageSize)
                     .Select(x => x.ToContract())
                     .ToArray()
             });
         }
         catch (Exception exception)
         {
             throw;
         }
     }
 }
Beispiel #2
0
        public PagedResult <Contracts.Vulnerability.Vulnerability> Get(PagedQuery pagedQuery, int[] excludeIds = null)
        {
            using (var db = new RAAPEntities(GetConnectionString()))
            {
                var itemQuery = db.Vulnerabilities.AsQueryable();

                if (excludeIds != null && excludeIds.Length > 0)
                {
                    itemQuery = itemQuery.Where(t => !excludeIds.Contains(t.VulnerabilityId));
                }

                var totalItems = itemQuery.Count();
                try
                {
                    return(new PagedResult <Contracts.Vulnerability.Vulnerability>()
                    {
                        CurrentPage = pagedQuery.Page,
                        TotalItems = totalItems,
                        TotalPages = pagedQuery.CalculatePages(totalItems),
                        Items =
                            itemQuery
                            .OrderByDirection(LinqHelper.OrderByDataContract <Vulnerability>(pagedQuery.OrderByKey),
                                              pagedQuery.IsDescending)
                            .Skip(pagedQuery.ItemsToSkip)
                            .Take(pagedQuery.PageSize)
                            .Select(x => x.ToContract())
                            .ToArray()
                    });
                }
                catch (Exception exception)
                {
                    throw;
                }
            }
        }
Beispiel #3
0
        public PagedResult <Contracts.Attribute.Attribute> Get(PagedQuery pagedQuery, string attributeTypeId, int[] excludeIds = null)
        {
            using (var db = new RAAPEntities(GetConnectionString()))
            {
                var query = db.Attributes.Where(a => a.AttributeTypeId == attributeTypeId);
                if (excludeIds != null && excludeIds.Length > 0)
                {
                    query = query.Where(t => !excludeIds.Contains(t.AttributeId));
                }

                var totalItems = query.Count();

                return(new PagedResult <Contracts.Attribute.Attribute>()
                {
                    CurrentPage = pagedQuery.Page,
                    TotalItems = totalItems,
                    TotalPages = pagedQuery.CalculatePages(totalItems),
                    Items =
                        query
                        .OrderByDirection(LinqHelper.OrderByDataContract <Database.Attribute>(pagedQuery.OrderByKey),
                                          pagedQuery.IsDescending)
                        .Skip(pagedQuery.ItemsToSkip)
                        .Take(pagedQuery.PageSize)
                        .Select(x => x.ToContract())
                        .ToArray()
                });
            }
        }
Beispiel #4
0
        public PagedResult <Contracts.Company.Company> Get(PagedQuery pagedQuery)
        {
            using (var db = new RAAPMasterEntities())
            {
                var totalItems = db.Companies.Count();

                return(new PagedResult <Contracts.Company.Company>
                {
                    CurrentPage = pagedQuery.Page,
                    TotalItems = totalItems,
                    TotalPages = pagedQuery.CalculatePages(totalItems),
                    Items = db.Companies.AsQueryable()
                            .OrderByDirection(LinqHelper.OrderByDataContract <Company>(pagedQuery.OrderByKey), pagedQuery.IsDescending)
                            .Skip(pagedQuery.ItemsToSkip)
                            .Take(pagedQuery.PageSize)
                            .Select(x => x.ToContract())
                            .ToArray()
                });
            }
        }
Beispiel #5
0
        public Contracts.Common.PagedResult <Contracts.Risk.RiskType> GetRiskTypes(PagedQuery pagedQuery)
        {
            using (var db = new RAAPEntities(GetConnectionString()))
            {
                var totalItems = db.RiskTypes.Count();

                return(new PagedResult <Contracts.Risk.RiskType>
                {
                    CurrentPage = pagedQuery.Page,
                    TotalItems = totalItems,
                    TotalPages = pagedQuery.CalculatePages(totalItems),
                    Items = db.RiskTypes.AsQueryable()
                            .OrderByDirection(LinqHelper.OrderByDataContract <RiskType>(pagedQuery.OrderByKey), pagedQuery.IsDescending)
                            .Skip(pagedQuery.ItemsToSkip)
                            .Take(pagedQuery.PageSize)
                            .Select(x => x.ToContract())
                            .ToArray()
                });
            }
        }
Beispiel #6
0
        public PagedResult <Contracts.User.User> Get(PagedQuery pagedQuery, int companyId)
        {
            using (var db = new RAAPMasterEntities())
            {
                var query      = db.Users.Where(u => u.CompanyId == companyId);
                var totalItems = query.Count();

                return(new PagedResult <Contracts.User.User>
                {
                    CurrentPage = pagedQuery.Page,
                    TotalItems = totalItems,
                    TotalPages = pagedQuery.CalculatePages(totalItems),
                    Items = query.AsQueryable()
                            .OrderByDirection(LinqHelper.OrderByDataContract <User>(pagedQuery.OrderByKey),
                                              pagedQuery.IsDescending)
                            .Skip(pagedQuery.ItemsToSkip)
                            .Take(pagedQuery.PageSize)
                            .Select(x => x.ToContract(false))
                            .ToArray()
                });
            }
        }
Beispiel #7
0
        public PagedResult <Contracts.AttributeCategory.AttributeCategory> Get(PagedQuery pagedQuery, string attributeTypeId)
        {
            using (var db = new RAAPEntities(GetConnectionString()))
            {
                var query = db.AttributeCategories.Where(a => a.AttributeTypeId == attributeTypeId);

                var totalItems = query.Count();

                return(new PagedResult <Contracts.AttributeCategory.AttributeCategory>()
                {
                    CurrentPage = pagedQuery.Page,
                    TotalItems = totalItems,
                    TotalPages = pagedQuery.CalculatePages(totalItems),
                    Items =
                        query
                        .OrderByDirection(LinqHelper.OrderByDataContract <AttributeCategory>(pagedQuery.OrderByKey),
                                          pagedQuery.IsDescending)
                        .Skip(pagedQuery.ItemsToSkip)
                        .Take(pagedQuery.PageSize)
                        .Select(x => x.ToContract())
                        .ToArray()
                });
            }
        }
Beispiel #8
0
        public PagedResult <Contracts.Attribute.Attribute> GetChilds(PagedQuery pagedQuery, int parentAttributeId)
        {
            using (var db = new RAAPEntities(GetConnectionString()))
            {
                var query = db.AttributeLinks.Where(al => al.ParentAttributeId == parentAttributeId).Select(al => al.Attribute);

                var totalItems = query.Count();

                return(new PagedResult <Contracts.Attribute.Attribute>()
                {
                    CurrentPage = pagedQuery.Page,
                    TotalItems = totalItems,
                    TotalPages = pagedQuery.CalculatePages(totalItems),
                    Items =
                        query
                        .OrderByDirection(LinqHelper.OrderByDataContract <Database.Attribute>(pagedQuery.OrderByKey),
                                          pagedQuery.IsDescending)
                        .Skip(pagedQuery.ItemsToSkip)
                        .Take(pagedQuery.PageSize)
                        .Select(x => x.ToContract())
                        .ToArray()
                });
            }
        }