This commit is contained in:
@@ -120,8 +120,8 @@ namespace AyaNova.Api.Controllers
|
|||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
UserBiz biz = new UserBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
UserBiz biz = new UserBiz(ct, UserIdFromContext.Id(HttpContext.Items), UserRolesFromContext.Roles(HttpContext.Items));
|
||||||
|
|
||||||
ApiPagedResponse<User> pr = await biz.GetManyAsync(Url, nameof(ListUsers), pagingOptions);
|
ApiPagedResponse<System.Object> pr = await biz.GetManyAsync(Url, nameof(ListUsers), pagingOptions);
|
||||||
return Ok(new ApiOkWithPagingResponse<User>(pr));
|
return Ok(new ApiOkWithPagingResponse<System.Object>(pr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -354,30 +354,12 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
//return success and link
|
//return success and link
|
||||||
//NOTE: this is a USER object so we don't want to return some key fields for security reasons
|
//NOTE: this is a USER object so we don't want to return some key fields for security reasons
|
||||||
//So the easiest way to do that is to return an anonymous object created on the fly
|
//which is why the object is "cleaned" before return
|
||||||
// var returnObject = new
|
|
||||||
// {
|
|
||||||
// Id = o.Id,
|
|
||||||
// ConcurrencyToken = o.ConcurrencyToken,
|
|
||||||
// OwnerId = o.OwnerId,
|
|
||||||
// Active = o.Active,
|
|
||||||
// Name = o.Name,
|
|
||||||
// Roles = o.Roles,
|
|
||||||
// LocaleId = o.LocaleId,
|
|
||||||
// UserType = o.UserType,
|
|
||||||
// EmployeeNumber = o.EmployeeNumber,
|
|
||||||
// Notes = o.Notes,
|
|
||||||
// ClientId = o.ClientId,
|
|
||||||
// HeadOfficeId = o.HeadOfficeId,
|
|
||||||
// SubVendorId = o.SubVendorId
|
|
||||||
// };
|
|
||||||
|
|
||||||
|
|
||||||
return CreatedAtAction("GetUser", new { id = o.Id }, new ApiCreatedResponse(UserBiz.CleanUserForReturn(o)));
|
return CreatedAtAction("GetUser", new { id = o.Id }, new ApiCreatedResponse(UserBiz.CleanUserForReturn(o)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//get many (paged)
|
//get many (paged)
|
||||||
internal async Task<ApiPagedResponse<User>> GetManyAsync(IUrlHelper Url, string routeName, PagingOptions pagingOptions)
|
internal async Task<ApiPagedResponse<System.Object>> GetManyAsync(IUrlHelper Url, string routeName, PagingOptions pagingOptions)
|
||||||
{
|
{
|
||||||
|
|
||||||
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
|
||||||
@@ -84,7 +84,14 @@ namespace AyaNova.Biz
|
|||||||
var totalRecordCount = await ct.User.CountAsync();
|
var totalRecordCount = await ct.User.CountAsync();
|
||||||
var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, totalRecordCount).PagingLinksObject();
|
var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, totalRecordCount).PagingLinksObject();
|
||||||
|
|
||||||
ApiPagedResponse<User> pr = new ApiPagedResponse<User>(items, pageLinks);
|
var cleanedItems = new System.Object[] { };
|
||||||
|
foreach (User item in items)
|
||||||
|
{
|
||||||
|
cleanedItems.Append(CleanUserForReturn(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ApiPagedResponse<System.Object> pr = new ApiPagedResponse<System.Object>(cleanedItems, pageLinks);
|
||||||
return pr;
|
return pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user