示例#1
0
        protected void DataPortal_Create(AttachmentCriteria criteria)
        {
            this.LoadProperty(SourceTypeProperty, criteria.SourceType);
            this.LoadProperty(SourceIdProperty, criteria.SourceId);

            this.BusinessRules.CheckRules();
        }
示例#2
0
        private void DataPortal_Fetch(AttachmentCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Attachments
                           .Single(row => row.AttachmentId == criteria.AttachmentId);

                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
示例#3
0
        private void DataPortal_Delete(AttachmentCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Attachments
                           .Single(row => row.AttachmentId == criteria.AttachmentId);

                ctx.ObjectContext.Attachments.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
        public ActionResult Index(int? sourceType, int? sourceId, string sortBy, string sortOrder)
        {
            var model = new AttachmentIndexModel();

            model.Tab = "Task";

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

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

            var attachments = AttachmentService.AttachmentFetchInfoList(criteria)
                .AsQueryable();

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

            model.Attachments = attachments;

            return this.View(model);
        }
示例#5
0
 internal static void DeleteAttachment(AttachmentCriteria criteria)
 {
     Csla.DataPortal.Delete <Attachment>(criteria);
 }
示例#6
0
 internal static Attachment FetchAttachment(AttachmentCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <Attachment>(criteria));
 }
示例#7
0
 internal static Attachment NewAttachment(AttachmentCriteria criteria)
 {
     return(Csla.DataPortal.Create <Attachment>(criteria));
 }
示例#8
0
 public static AttachmentInfoList AttachmentFetchInfoList(AttachmentCriteria criteria)
 {
     return AttachmentInfoList.FetchAttachmentInfoList(criteria);
 }
 internal static AttachmentInfoList FetchAttachmentInfoList(AttachmentCriteria criteria)
 {
     return Csla.DataPortal.Fetch<AttachmentInfoList>(criteria);
 }
        private void DataPortal_Fetch(AttachmentCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly             = false;

                IQueryable <Data.Attachment> query = ctx.ObjectContext.Attachments;

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

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

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

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

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

                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(AttachmentInfo.FetchAttachmentInfo);

                this.AddRange(data);

                this.IsReadOnly             = true;
                this.RaiseListChangedEvents = true;
            }
        }
示例#11
0
 internal static Attachment NewAttachment(AttachmentCriteria criteria)
 {
     return Csla.DataPortal.Create<Attachment>(criteria);
 }
示例#12
0
 internal static void DeleteAttachment(AttachmentCriteria criteria)
 {
     Csla.DataPortal.Delete<Attachment>(criteria);
 }