protected void DataPortal_Create(NoteCriteria criteria) { this.LoadProperty(SourceTypeProperty, criteria.SourceType); this.LoadProperty(SourceIdProperty, criteria.SourceId.First()); this.BusinessRules.CheckRules(); }
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)); }
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); }
public static NoteInfoList NoteFetchInfoList(NoteCriteria criteria) { return(NoteInfoList.FetchNoteInfoList(criteria)); }
internal static Note NewNote(NoteCriteria criteria) { return Csla.DataPortal.Create<Note>(criteria); }
internal static Note FetchNote(NoteCriteria criteria) { return Csla.DataPortal.Fetch<Note>(criteria); }
internal static void DeleteNote(NoteCriteria criteria) { Csla.DataPortal.Delete<Note>(criteria); }
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; } }
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(); } }
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(); } }