public virtual IActionResult GetEntityCountLong([FromRoute] string entityName) { try { string requestName = $"{nameof(GetEntityCount)} : Entity Name = {entityName}"; LogWebRequest(requestName, null); ValidateRequestMethod(HttpVerb.GET); string userName = GetCurrentUserName(); Type entityType = GetEntityType(entityName); OnBeforeGetEntities?.Invoke(this, new NKitRestApiGetEntitiesEventArgs(entityName, userName, DbContext, entityType, null, null, null)); long result = DbContext.GetTotalCountLong(entityType); OnAfterGetEntities?.Invoke(this, new NKitRestApiGetEntitiesEventArgs(entityName, userName, DbContext, entityType, null, null, new List <object>() { result })); string serializedText = GetSerializer().SerializeToText(result, GetNKitSerializerModelTypes()); LogWebResponse(requestName, serializedText); Response.ContentType = WebApiControllerSettings.ResponseContentType; return(Ok(serializedText)); } finally { DisposeEntityContext(); } }
public virtual IActionResult GetEntities([FromRoute] string entityName, [FromQuery] string searchBy, [FromQuery] string searchValueOf) { try { string requestName = $"{nameof(GetEntities)} : Entity Name = {entityName} : Search by = {searchBy} : Search by value = {searchValueOf}"; LogWebRequest(requestName, null); ValidateRequestMethod(HttpVerb.GET); string userName = GetCurrentUserName(); Type entityType = GetEntityType(entityName); OnBeforeGetEntities?.Invoke(this, new NKitRestApiGetEntitiesEventArgs(entityName, userName, DbContext, entityType, searchBy, searchValueOf, null)); List <object> outputEntities = string.IsNullOrEmpty(searchBy) ? DbContext.GetAllEntities(entityType) : DbContext.GetEntitiesByField(entityType, searchBy, searchValueOf); OnAfterGetEntities?.Invoke(this, new NKitRestApiGetEntitiesEventArgs(entityName, userName, DbContext, entityType, searchBy, searchValueOf, outputEntities)); string serializedText = GetSerializer().SerializeToText(outputEntities, GetNKitSerializerModelTypes()); LogWebResponse(requestName, serializedText); Response.ContentType = WebApiControllerSettings.ResponseContentType; return(Ok(serializedText)); } finally { DisposeEntityContext(); } }