示例#1
0
        public async Task <IActionResult> GetAllUsersWithSearch(UserSearchFilterDTO dto)
        {
            try
            {
                var sp     = new SpGetUsersWithSearchAndFilter();
                var result = await sp.ExecuteSp(dto);

                return(APIResponseCreator.GetResponse(ResponseCode.SUCCESS_CODE, "Success", result, System.Net.HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                return(APIResponseCreator.GetResponse(ResponseCode.FAILED_CODE, ex.ToString(), null, System.Net.HttpStatusCode.OK));
            }
        }
示例#2
0
 public async Task <IList <SpGetUsersWithSearchAndFilterResultModels> > ExecuteSp(UserSearchFilterDTO dto)
 {
     return(await Execute(dto));
 }
示例#3
0
        private async Task <IList <SpGetUsersWithSearchAndFilterResultModels> > Execute(UserSearchFilterDTO dto)
        {
            var spParams = new List <SqlParameter>
            {
                new SqlParameter("@SearchText", string.IsNullOrEmpty(dto.SearchText)?DBNull.Value:(object)dto.SearchText),
                new SqlParameter("@PageSize", (dto.PageSize == null || dto.PageSize == 0)?DBNull.Value:(object)dto.PageSize),
                new SqlParameter("@PageNumber", (dto.PageNumber == null || dto.PageNumber == 0)?DBNull.Value:(object)dto.PageNumber),
                new SqlParameter("@IsActive", dto.IsActive == null?DBNull.Value:(object)dto.IsActive)
            };
            var product = await context.SpGetUsersWithSearchAndFilterResultModels
                          .FromSql(ExecuteUspStatement, spParams.ToArray())
                          .ToListAsync();

            return(product);
        }