Ejemplo n.º 1
0
        private void DataPortal_Fetch(CategoryCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                IQueryable <Data.Category> query = ctx.ObjectContext.Categories;

                if (criteria.CategoryId != null)
                {
                    query = query.Where(row => row.CategoryId == criteria.CategoryId);
                }

                if (criteria.Name != null)
                {
                    query = query.Where(row => row.Name == criteria.Name);
                }

                var data = query.Single();


                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
Ejemplo n.º 2
0
        private void DataPortal_Delete(CategoryCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Categories
                           .Single(row => row.CategoryId == criteria.CategoryId);

                ctx.ObjectContext.Categories.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
 internal static CategoryInfoList FetchCategoryInfoList(CategoryCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <CategoryInfoList>(criteria));
 }
Ejemplo n.º 4
0
        private void DataPortal_Fetch(CategoryCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                IQueryable<Data.Category> query = ctx.ObjectContext.Categories;

                if (criteria.CategoryId != null)
                {
                    query = query.Where(row => row.CategoryId == criteria.CategoryId);
                }

                if (criteria.Name != null)
                {
                    query = query.Where(row => row.Name == criteria.Name);
                }

                var data = query.Single();

                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
 internal static CategoryInfoList FetchCategoryInfoList(CategoryCriteria criteria)
 {
     return Csla.DataPortal.Fetch<CategoryInfoList>(criteria);
 }
Ejemplo n.º 6
0
        private void DataPortal_Delete(CategoryCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Categories
                    .Single(row => row.CategoryId == criteria.CategoryId);

                ctx.ObjectContext.Categories.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Ejemplo n.º 7
0
 internal static void DeleteCategory(CategoryCriteria criteria)
 {
     Csla.DataPortal.Delete <Category>(criteria);
 }
Ejemplo n.º 8
0
 internal static CategoryInfoList CategoryFetchInfoList(CategoryCriteria criteria)
 {
     return CategoryInfoList.FetchCategoryInfoList(criteria);
 }
Ejemplo n.º 9
0
 internal static Category FetchCategory(CategoryCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <Category>(criteria));
 }
Ejemplo n.º 10
0
        private void DataPortal_Fetch(CategoryCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly = false;

                IQueryable<Data.Category> query = ctx.ObjectContext.Categories;

                if (criteria.CategoryId != null)
                {
                    query = query.Where(row => row.CategoryId == criteria.CategoryId);
                }

                if (criteria.Name != null)
                {
                    query = query.Where(row => row.Name == criteria.Name);
                }

                if (criteria.Description != null)
                {
                    query = query.Where(row => row.Description == criteria.Description);
                }

                if (criteria.Ordinal != null)
                {
                    query = query.Where(row => row.Ordinal == criteria.Ordinal);
                }

                if (criteria.ForeColor != null)
                {
                    query = query.Where(row => row.ForeColor == criteria.ForeColor);
                }

                if (criteria.BackColor != null)
                {
                    query = query.Where(row => row.BackColor == criteria.BackColor);
                }

                if (criteria.IsActive != null)
                {
                    query = query.Where(row => row.IsActive == criteria.IsActive);
                }

                if (criteria.IsArchived != null)
                {
                    query = query.Where(row => row.IsArchived == criteria.IsArchived);
                }

                if (criteria.ModifiedBy != null)
                {
                    query = query.Where(row => row.ModifiedBy == criteria.ModifiedBy);
                }

                if (criteria.ModifiedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate >= criteria.ModifiedDate.DateFrom);
                }

                if (criteria.ModifiedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate <= criteria.ModifiedDate.DateTo);
                }

                if (criteria.CreatedBy != null)
                {
                    query = query.Where(row => row.CreatedBy == criteria.CreatedBy);
                }

                if (criteria.CreatedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CreatedDate >= criteria.CreatedDate.DateFrom);
                }

                if (criteria.CreatedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CreatedDate <= criteria.CreatedDate.DateTo);
                }

                if (criteria.SortBy != null)
                {
                    query = query.OrderBy(string.Format(
                        "{0} {1}",
                        criteria.SortBy,
                        criteria.SortOrder == ListSortDirection.Ascending ? "ASC" : "DESC"));
                }

                if (criteria.MaximumRecords != null)
                {
                    query = query.Take(criteria.MaximumRecords.Value);
                }

                var data = query.AsEnumerable().Select(CategoryInfo.FetchCategoryInfo);

                this.AddRange(data);

                this.IsReadOnly = true;
                this.RaiseListChangedEvents = true;
            }
        }
Ejemplo n.º 11
0
 internal static Category FetchCategory(CategoryCriteria criteria)
 {
     return Csla.DataPortal.Fetch<Category>(criteria);
 }
Ejemplo n.º 12
0
 internal static void DeleteCategory(CategoryCriteria criteria)
 {
     Csla.DataPortal.Delete<Category>(criteria);
 }
Ejemplo n.º 13
0
        private void DataPortal_Fetch(CategoryCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly             = false;

                IQueryable <Data.Category> query = ctx.ObjectContext.Categories;

                if (criteria.CategoryId != null)
                {
                    query = query.Where(row => row.CategoryId == criteria.CategoryId);
                }

                if (criteria.Name != null)
                {
                    query = query.Where(row => row.Name == criteria.Name);
                }

                if (criteria.Description != null)
                {
                    query = query.Where(row => row.Description == criteria.Description);
                }

                if (criteria.Ordinal != null)
                {
                    query = query.Where(row => row.Ordinal == criteria.Ordinal);
                }

                if (criteria.ForeColor != null)
                {
                    query = query.Where(row => row.ForeColor == criteria.ForeColor);
                }

                if (criteria.BackColor != null)
                {
                    query = query.Where(row => row.BackColor == criteria.BackColor);
                }

                if (criteria.IsActive != null)
                {
                    query = query.Where(row => row.IsActive == criteria.IsActive);
                }

                if (criteria.IsArchived != null)
                {
                    query = query.Where(row => row.IsArchived == criteria.IsArchived);
                }

                if (criteria.ModifiedBy != null)
                {
                    query = query.Where(row => row.ModifiedBy == criteria.ModifiedBy);
                }

                if (criteria.ModifiedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate >= criteria.ModifiedDate.DateFrom);
                }

                if (criteria.ModifiedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate <= criteria.ModifiedDate.DateTo);
                }

                if (criteria.CreatedBy != null)
                {
                    query = query.Where(row => row.CreatedBy == criteria.CreatedBy);
                }

                if (criteria.CreatedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CreatedDate >= criteria.CreatedDate.DateFrom);
                }

                if (criteria.CreatedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CreatedDate <= criteria.CreatedDate.DateTo);
                }

                if (criteria.SortBy != null)
                {
                    query = query.OrderBy(string.Format(
                                              "{0} {1}",
                                              criteria.SortBy,
                                              criteria.SortOrder == ListSortDirection.Ascending ? "ASC" : "DESC"));
                }

                if (criteria.MaximumRecords != null)
                {
                    query = query.Take(criteria.MaximumRecords.Value);
                }

                var data = query.AsEnumerable().Select(CategoryInfo.FetchCategoryInfo);

                this.AddRange(data);

                this.IsReadOnly             = true;
                this.RaiseListChangedEvents = true;
            }
        }