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

            this.BusinessRules.CheckRules();
        }
Beispiel #2
0
        public ActionResult Index(int?sourceType, int?sourceId, string sortBy, string sortOrder)
        {
            var model = new NoteIndexModel();

            model.Tab = "Task";

            model.SortBy    = sortBy ?? "Name";
            model.SortOrder = sortOrder ?? "ASC";
            model.SortableColumns.Add("Name", "Name");

            var criteria = new NoteCriteria()
            {
                SourceType = DataHelper.ToSourceType(sourceType)
            };

            var notes = NoteService.NoteFetchInfoList(criteria)
                        .AsQueryable();

            notes = notes.OrderBy(string.Format("{0} {1}", model.SortBy, model.SortOrder));

            model.Notes = notes;

            return(this.View(model));
        }
Beispiel #3
0
        public ActionResult Index(int? sourceType, int? sourceId, string sortBy, string sortOrder)
        {
            var model = new NoteIndexModel();

            model.Tab = "Task";

            model.SortBy = sortBy ?? "Name";
            model.SortOrder = sortOrder ?? "ASC";
            model.SortableColumns.Add("Name", "Name");

            var criteria = new NoteCriteria()
            {
                SourceType = DataHelper.ToSourceType(sourceType)
            };

            var notes = NoteService.NoteFetchInfoList(criteria)
                .AsQueryable();

            notes = notes.OrderBy(string.Format("{0} {1}", model.SortBy, model.SortOrder));

            model.Notes = notes;

            return this.View(model);
        }
 internal static NoteInfoList FetchNoteInfoList(NoteCriteria criteria)
 {
     return Csla.DataPortal.Fetch<NoteInfoList>(criteria);
 }
Beispiel #5
0
 public static NoteInfoList NoteFetchInfoList(NoteCriteria criteria)
 {
     return(NoteInfoList.FetchNoteInfoList(criteria));
 }
Beispiel #6
0
 internal static Note NewNote(NoteCriteria criteria)
 {
     return Csla.DataPortal.Create<Note>(criteria);
 }
Beispiel #7
0
 internal static Note FetchNote(NoteCriteria criteria)
 {
     return Csla.DataPortal.Fetch<Note>(criteria);
 }
Beispiel #8
0
 internal static void DeleteNote(NoteCriteria criteria)
 {
     Csla.DataPortal.Delete<Note>(criteria);
 }
Beispiel #9
0
 public static NoteInfoList NoteFetchInfoList(NoteCriteria criteria)
 {
     return NoteInfoList.FetchNoteInfoList(criteria);
 }
        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;
            }
        }
Beispiel #11
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();
            }
        }
Beispiel #12
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();
            }
        }