Exemplo n.º 1
0
        protected void DataPortal_Create(NoteCriteria criteria)
        {
            this.LoadProperty(SourceTypeProperty, criteria.SourceType);
            this.LoadProperty(SourceIdProperty, criteria.SourceId.First());

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

                ctx.ObjectContext.Notes.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Exemplo n.º 3
0
        private void DataPortal_Fetch(NoteCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Notes
                           .Include("ModifiedByUser")
                           .Include("CreatedByUser")
                           .Single(row => row.NoteId == criteria.NoteId);

                this.Fetch(data);

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

                IQueryable <Data.Note> query = ctx.ObjectContext.Notes
                                               .Include("ModifiedByUser")
                                               .Include("CreatedByUser");

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

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

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

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

                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(NoteInfo.FetchNoteInfo);

                this.AddRange(data);

                this.IsReadOnly             = true;
                this.RaiseListChangedEvents = true;
            }
        }
Exemplo n.º 5
0
 internal static NoteInfoList FetchNoteInfoList(NoteCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <NoteInfoList>(criteria));
 }
Exemplo n.º 6
0
 internal static void DeleteNote(NoteCriteria criteria)
 {
     Csla.DataPortal.Delete <Note>(criteria);
 }
Exemplo n.º 7
0
 internal static Note FetchNote(NoteCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <Note>(criteria));
 }
Exemplo n.º 8
0
 internal static Note NewNote(NoteCriteria criteria)
 {
     return(Csla.DataPortal.Create <Note>(criteria));
 }