public bool Validate(RoleParameters rp) { if (mainTimeline == null) { return(false); } if (mainTimeline.sequence.Length == 0) { return(false); } if (mainTimeline.sequence[0].kind != TimeLineItem.Kind.Syncro) { return(false); } if (mainTimeline.sequence[mainTimeline.sequence.Length - 1].kind != TimeLineItem.Kind.Syncro) { return(false); } bool success = true; foreach (LifeSceneRoleTimeLine tl in timeLineForRoles) { success = tl.Validate() && success; } return(success); }
/// <inheritdoc /> public async Task <PagedList <Role> > GetAll(RoleParameters parameters = null) { var roles = this.GetQueryable(); if (parameters != null) { } else { parameters = new RoleParameters(); } return(await PagedList <Role> .CreateAsync(roles, parameters.PageNumber, parameters.PageSize)); }
public async Task <IActionResult> GetAll([FromQuery] RoleParameters parameters) { var roles = await this.Repository.GetAll(parameters); var roleDtos = roles.Select(l => this.Mapper.Map <RoleDto>(l)).ToList(); this.Response.AddPaginationHeader(new PaginationHeader ( roles.PageNumber, roles.PageSize, roles.TotalPages, roles.TotalCount )); return(this.Ok(roleDtos)); }
public ActionResult <IQueryable <IdentityRole> > Get([FromQuery] RoleParameters roleParameters) { var roles = _roleManager.Roles; var result = PagedList <IdentityRole> .ToPagedList(roles, roleParameters.PageNumber, roleParameters.PageSize); var metadata = new { result.TotalCount, result.PageSize, result.CurrentPage, result.TotalPages, result.HasNext, result.HasPrevious }; Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(metadata)); return(Ok(result)); }
public async Task <IActionResult> GetRolesWithPage([FromQuery] RoleParameters roleParameters) { var find = await _context.Roles .Where(r => EF.Functions.Like(r.Id.ToString(), $"%{roleParameters.Text}%") || EF.Functions.Like(r.Name, $"%{roleParameters.Text}%") ).ToListAsync(); roleParameters.TotalCount = find.Count; if (!roleParameters.Check()) { return(NoContent()); } Response.Headers.Add("X-Pagination", roleParameters.PaginationToJson()); List <RoleDTO> dtos = new List <RoleDTO>(); foreach (var item in find) { dtos.Add(item.ToRoleDTO()); } return(Ok(dtos)); }
public bool Validate( RoleParameters rp ) { if( mainTimeline == null ) return false; if( mainTimeline.sequence.Length == 0 ) return false; if( mainTimeline.sequence[0].kind != TimeLineItem.Kind.Syncro ) return false; if( mainTimeline.sequence[mainTimeline.sequence.Length-1].kind != TimeLineItem.Kind.Syncro ) return false; bool success = true; foreach( LifeSceneRoleTimeLine tl in timeLineForRoles ) success = tl.Validate() && success; return success; }
void ValidateTimeLine( RoleParameters rp, LifeSceneTimeLine timeLine) { // at least 1 sync point if( timeLine.mainTimeline == null ) { timeLine.mainTimeline = new LifeSceneRoleTimeLine(); timeLine.mainTimeline.sequence = new TimeLineItem[0]; } if( timeLine.mainTimeline.sequence.Length == 0 ) { ArrayUtility.Add(ref timeLine.mainTimeline.sequence, new TimeLineItem( CreateUID() )); } // remove timeline not associated with a role timeLine.timeLineForRoles = timeLine.timeLineForRoles.Where(tl => rp.Roles.Contains( tl.roleName) ).ToArray(); // check each role has a timeLine foreach (string role in rp.Roles) { LifeSceneRoleTimeLine tl = timeLine.FindTimeLineForRole(role); // add one if none exists if (tl == null) { tl = new LifeSceneRoleTimeLine(); tl.roleName = role; ArrayUtility.Add(ref timeLine.timeLineForRoles, tl); } if( tl.sequence == null ) tl.sequence = new TimeLineItem[0]; if( tl.sequence.Length == 0 ) { foreach ( TimeLineItem main in timeLine.mainTimeline.sequence) { TimeLineItem item; if (main.kind == TimeLineItem.Kind.Syncro) item = new TimeLineItem(main.syncID); else item = new TimeLineItem(); ArrayUtility.Add(ref tl.sequence, item); } } } }