internal void SetPagingValues(ObjectAndControlData controlData, IObjectFacade nakedObject) { if (nakedObject.Specification.IsCollection) { int sink1, sink2; CurrentlyPaging(controlData, nakedObject.Count(), out sink1, out sink2); } }
internal IObjectFacade FilterCollection(IObjectFacade nakedObject, ObjectAndControlData controlData) { var form = controlData.Form; if (form != null && nakedObject != null && nakedObject.Specification.IsCollection) { nakedObject = Page(nakedObject, nakedObject.Count(), controlData); var map = nakedObject.ToEnumerable().ToDictionary(x => Facade.OidTranslator.GetOidTranslation(x).Encode(), y => y.GetDomainObject <object>()); var selected = map.Where(kvp => form.Keys.Cast <string>().Contains(kvp.Key) && form[kvp.Key].Contains("true")).Select(kvp => kvp.Value).ToArray(); return(nakedObject.Select(selected, false)); } return(nakedObject); }
// custom extension for pagination private void SetPagination(IObjectFacade list, RestControlFlags flags) { Pagination = new MapRepresentation(); var totalCount = list.Count(); var pageSize = flags.PageSize ; var page = flags.Page; var numPages = (int)Math.Round(totalCount / (decimal)pageSize + 0.5m); numPages = numPages == 0 ? 1 : numPages; var exts = new Dictionary<string, object> { {"page", page}, {"pageSize", pageSize}, {"numPages", numPages}, {"totalCount", totalCount} }; Pagination = RestUtils.CreateMap(exts); }
// custom extension for pagination private void SetPagination(IObjectFacade list, RestControlFlags flags, ActionContextFacade actionContext) { Pagination = new MapRepresentation(); var totalCount = list.Count(); var pageSize = PageSize(flags, actionContext); var page = flags.Page; var numPages = (int) Math.Round(totalCount/(decimal) pageSize + 0.5m); numPages = numPages == 0 ? 1 : numPages; var exts = new Dictionary<string, object> { {JsonPropertyNames.Page, page}, {JsonPropertyNames.PageSize, pageSize}, {JsonPropertyNames.NumPages, numPages}, {JsonPropertyNames.TotalCount, totalCount} }; Pagination = RestUtils.CreateMap(exts); }
// custom extension for pagination private void SetPagination(IObjectFacade list, RestControlFlags flags, ActionContextFacade actionContext) { Pagination = new MapRepresentation(); var totalCount = list.Count(); var pageSize = PageSize(flags, actionContext); var page = flags.Page; var numPages = (int)Math.Round(totalCount / (decimal)pageSize + 0.5m); numPages = numPages == 0 ? 1 : numPages; var exts = new Dictionary <string, object> { { JsonPropertyNames.Page, page }, { JsonPropertyNames.PageSize, pageSize }, { JsonPropertyNames.NumPages, numPages }, { JsonPropertyNames.TotalCount, totalCount } }; Pagination = RestUtils.CreateMap(exts); }
// custom extension for pagination private void SetPagination(IObjectFacade list, RestControlFlags flags) { Pagination = new MapRepresentation(); var totalCount = list.Count(); var pageSize = flags.PageSize; var page = flags.Page; var numPages = (int)Math.Round(totalCount / (decimal)pageSize + 0.5m); numPages = numPages == 0 ? 1 : numPages; var exts = new Dictionary <string, object> { { "page", page }, { "pageSize", pageSize }, { "numPages", numPages }, { "totalCount", totalCount } }; Pagination = RestUtils.CreateMap(exts); }
internal ActionResult AppropriateView(ObjectAndControlData controlData, IObjectFacade nakedObject, IActionFacade action = null, string propertyName = null) { if (nakedObject == null) { // no object to go to // if action on object go to that object. // if action on collection go to collection // if action on service go to last object nakedObject = controlData.GetNakedObject(Facade); if (nakedObject.Specification.IsService) { object lastObject = Session.LastObject(Facade, ObjectCache.ObjectFlag.BreadCrumb); if (lastObject == null) { return(RedirectHome()); } nakedObject = Facade.GetObject(lastObject); } if (nakedObject.IsCollectionMemento) { // if we have returned null and existing object is collection memento need to make // sure action remains action from original collectionMemento. action = nakedObject.MementoAction; } } if (nakedObject.Specification.IsCollection && !nakedObject.Specification.IsParseable) { int collectionSize = nakedObject.Count(); if (collectionSize == 1) { // remove any paging data - to catch case where custom page has embedded standalone collection as paging data will confuse rendering ViewData.Remove(IdConstants.PagingData); // is this safe TODO !! return(View("ObjectView", nakedObject.ToEnumerable().First().GetDomainObject())); } nakedObject = Page(nakedObject, collectionSize, controlData); // todo is there a better way to do this ? action = action ?? nakedObject.MementoAction; int page, pageSize; CurrentlyPaging(controlData, collectionSize, out page, out pageSize); var format = ViewData["NofCollectionFormat"] as string; return(View("StandaloneTable", ActionResultModel.Create(Facade, action, nakedObject, page, pageSize, format))); } // remove any paging data - to catch case where custom page has embedded standalone collection as paging data will confuse rendering ViewData.Remove(IdConstants.PagingData); if (controlData.DataDict.Values.Contains("max")) { // maximizing an inline object - do not update history ViewData.Add("updateHistory", false); } return(propertyName == null?View(nakedObject.IsNotPersistent? "ObjectView" : "ViewNameSetAfterTransaction", nakedObject.GetDomainObject()) : View(nakedObject.IsNotPersistent ? "PropertyView" : "ViewNameSetAfterTransaction", new PropertyViewModel(nakedObject.GetDomainObject(), propertyName))); }
internal ActionResult AppropriateView(ObjectAndControlData controlData, IObjectFacade nakedObject, IActionFacade action = null, string propertyName = null) { if (nakedObject == null) { // no object to go to // if action on object go to that object. // if action on collection go to collection // if action on service go to last object nakedObject = controlData.GetNakedObject(Facade); if (nakedObject.Specification.IsService) { object lastObject = Session.LastObject(Facade, ObjectCache.ObjectFlag.BreadCrumb); if (lastObject == null) { return RedirectHome(); } nakedObject = Facade.GetObject(lastObject); } if (nakedObject.IsCollectionMemento) { // if we have returned null and existing object is collection memento need to make // sure action remains action from original collectionMemento. action = nakedObject.MementoAction; } } if (nakedObject.Specification.IsCollection && !nakedObject.Specification.IsParseable) { int collectionSize = nakedObject.Count(); if (collectionSize == 1) { // remove any paging data - to catch case where custom page has embedded standalone collection as paging data will confuse rendering ViewData.Remove(IdConstants.PagingData); // is this safe TODO !! return View("ObjectView", nakedObject.ToEnumerable().First().GetDomainObject()); } nakedObject = Page(nakedObject, collectionSize, controlData); // todo is there a better way to do this ? action = action ?? nakedObject.MementoAction; int page, pageSize; CurrentlyPaging(controlData, collectionSize, out page, out pageSize); var format = ViewData["NofCollectionFormat"] as string; return View("StandaloneTable", ActionResultModel.Create(Facade, action, nakedObject, page, pageSize, format)); } // remove any paging data - to catch case where custom page has embedded standalone collection as paging data will confuse rendering ViewData.Remove(IdConstants.PagingData); if (controlData.DataDict.Values.Contains("max")) { // maximizing an inline object - do not update history ViewData.Add("updateHistory", false); } return propertyName == null ? View(nakedObject.IsNotPersistent ? "ObjectView" : "ViewNameSetAfterTransaction", nakedObject.GetDomainObject()) : View(nakedObject.IsNotPersistent ? "PropertyView" : "ViewNameSetAfterTransaction", new PropertyViewModel(nakedObject.GetDomainObject(), propertyName)); }
internal IObjectFacade FilterCollection(IObjectFacade nakedObject, ObjectAndControlData controlData) { var form = controlData.Form; if (form != null && nakedObject != null && nakedObject.Specification.IsCollection) { nakedObject = Page(nakedObject, nakedObject.Count(), controlData); var map = nakedObject.ToEnumerable().ToDictionary(x => Facade.OidTranslator.GetOidTranslation(x).Encode(), y => y.GetDomainObject<object>()); var selected = map.Where(kvp => form.Keys.Cast<string>().Contains(kvp.Key) && form[kvp.Key].Contains("true")).Select(kvp => kvp.Value).ToArray(); return nakedObject.Select(selected, false); } return nakedObject; }