Example #1
0
        public ResponseModels <MsGroup> Inquiry(GroupReqModel req)
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            try
            {
                _logger.LogInformation($"Start Function => {methodName}, Parameters => {JsonSerializer.ToJsonString(req)}");

                var query  = _context.MsGroup.Where(r => string.IsNullOrEmpty(req.Filter) || r.Name.Contains(req.Filter));
                var datas  = query.OrderByDescending(r => r.CreateDate).Skip((req.Page - 1) * req.RowsPerPage).Take(req.RowsPerPage).ToList();
                var total  = query.Count();
                var result = new ResponseModels <MsGroup>
                {
                    Success = true,
                    Datas   = datas,
                    Total   = total
                };

                _logger.LogInformation($"Finish Function => {methodName}, Result => {JsonSerializer.ToJsonString(result)}");
                return(result);
            }
            catch (Exception ex)
            {
                var messageError = $"Error Function => {methodName}";
                _logger.LogError(ex, messageError);
                throw new ArgumentException(messageError, ex);
            }
        }
Example #2
0
        public ResponseModels <MsGroup> Inquiry(GroupReqModel req)
        {
            var result = new ResponseModels <MsGroup>();

            try
            {
                result = _msGroupService.Inquiry(req);
                return(result);
            }
            catch
            {
                return(new ResponseModels <MsGroup>
                {
                    Message = result.Message,
                    StatusCode = StatusCodes.Status500InternalServerError
                });
            }
        }