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

            this.BusinessRules.CheckRules();
        }
Esempio 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();
            }
        }
Esempio 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();
            }
        }
Esempio 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;
            }
        }
 internal static NoteInfoList FetchNoteInfoList(NoteCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <NoteInfoList>(criteria));
 }
Esempio n. 6
0
 internal static void DeleteNote(NoteCriteria criteria)
 {
     Csla.DataPortal.Delete <Note>(criteria);
 }
Esempio n. 7
0
 internal static Note FetchNote(NoteCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <Note>(criteria));
 }
Esempio n. 8
0
 internal static Note NewNote(NoteCriteria criteria)
 {
     return(Csla.DataPortal.Create <Note>(criteria));
 }