コード例 #1
0
ファイル: Note.Data.cs プロジェクト: WhiteIsland/epiworx
        protected void DataPortal_Create(NoteCriteria criteria)
        {
            this.LoadProperty(SourceTypeProperty, criteria.SourceType);
            this.LoadProperty(SourceIdProperty, criteria.SourceId.First());

            this.BusinessRules.CheckRules();
        }
コード例 #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));
        }
コード例 #3
0
ファイル: NoteController.cs プロジェクト: WhiteIsland/epiworx
        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);
        }
コード例 #4
0
 internal static NoteInfoList FetchNoteInfoList(NoteCriteria criteria)
 {
     return Csla.DataPortal.Fetch<NoteInfoList>(criteria);
 }
コード例 #5
0
ファイル: NoteService.cs プロジェクト: WhiteIsland/epiworx
 public static NoteInfoList NoteFetchInfoList(NoteCriteria criteria)
 {
     return(NoteInfoList.FetchNoteInfoList(criteria));
 }
コード例 #6
0
ファイル: Note.Methods.cs プロジェクト: WhiteIsland/epiworx
 internal static Note NewNote(NoteCriteria criteria)
 {
     return Csla.DataPortal.Create<Note>(criteria);
 }
コード例 #7
0
ファイル: Note.Methods.cs プロジェクト: WhiteIsland/epiworx
 internal static Note FetchNote(NoteCriteria criteria)
 {
     return Csla.DataPortal.Fetch<Note>(criteria);
 }
コード例 #8
0
ファイル: Note.Methods.cs プロジェクト: WhiteIsland/epiworx
 internal static void DeleteNote(NoteCriteria criteria)
 {
     Csla.DataPortal.Delete<Note>(criteria);
 }
コード例 #9
0
ファイル: NoteService.cs プロジェクト: WhiteIsland/epiworx
 public static NoteInfoList NoteFetchInfoList(NoteCriteria criteria)
 {
     return NoteInfoList.FetchNoteInfoList(criteria);
 }
コード例 #10
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;
            }
        }
コード例 #11
0
ファイル: Note.Data.cs プロジェクト: WhiteIsland/epiworx
        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();
            }
        }
コード例 #12
0
ファイル: Note.Data.cs プロジェクト: WhiteIsland/epiworx
        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();
            }
        }