Ejemplo n.º 1
0
        private void DataPortal_Delete(UserCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Users
                           .Single(row => row.UserId == criteria.UserId);

                ctx.ObjectContext.Users.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        private void DataPortal_Fetch(UserCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                IQueryable <Data.User> query = ctx.ObjectContext.Users;

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

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

                var data = query.Single();

                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
Ejemplo n.º 3
0
        private void DataPortal_Fetch(UserCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly             = false;

                IQueryable <Data.User> query = ctx.ObjectContext.Users;

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

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

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

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

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

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

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

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

                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.Notes != null)
                {
                    query = query.Where(row => row.Notes == criteria.Notes);
                }

                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(UserInfo.FetchUserInfo);

                this.AddRange(data);

                this.IsReadOnly             = true;
                this.RaiseListChangedEvents = true;
            }
        }
Ejemplo n.º 4
0
        private void DataPortal_Fetch(UserCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                IQueryable<Data.User> query = ctx.ObjectContext.Users;

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

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

                var data = query.Single();

                this.Fetch(data);

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

                ctx.ObjectContext.Users.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Ejemplo n.º 6
0
 internal static void DeleteUser(UserCriteria criteria)
 {
     Csla.DataPortal.Delete <User>(criteria);
 }
Ejemplo n.º 7
0
 internal static User FetchUser(UserCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <User>(criteria));
 }
Ejemplo n.º 8
0
 internal static UserInfoList FetchUserInfoList(UserCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <UserInfoList>(criteria));
 }
Ejemplo n.º 9
0
 internal static User FetchUser(UserCriteria criteria)
 {
     return Csla.DataPortal.Fetch<User>(criteria);
 }
Ejemplo n.º 10
0
 internal static void DeleteUser(UserCriteria criteria)
 {
     Csla.DataPortal.Delete<User>(criteria);
 }