public async Task <IActionResult> GetById([FromBody] ManufacturerGetRequest request)
        {
            try
            {
                if (string.IsNullOrEmpty(request.Id))
                {
                    return(Json(new ManufacturerGetResponse()));
                }
                else
                {
                    var response = await _manufacturerAppService.GetById(request);

                    return(Json(response));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, Common.Common.GetMethodName());
                throw;
            }
        }
Exemple #2
0
        public async Task <ManufacturerGetResponse> Search(ManufacturerGetRequest request)
        {
            ManufacturerGetResponse response = new ManufacturerGetResponse();

            try
            {
                var manufacturers = await _manufacturerService.Search(request);

                if (manufacturers == null)
                {
                    response.SetFail(BaseResponse.ErrorCodeEnum.UserNotFound);
                    return(response);
                }
                response.Manufacturers = manufacturers.Select(p => p.ToModel()).ToArray();
            }
            catch (Exception e)
            {
                response.SetFail(e);
                _logger.LogError(e, e.Message, request);
            }
            return(response);
        }
Exemple #3
0
        public async Task <ManufacturerGetResponse> GetById(ManufacturerGetRequest request)
        {
            ManufacturerGetResponse response = new ManufacturerGetResponse();

            try
            {
                var manufacturer = await _manufacturerService.GetById(request.Id);

                if (manufacturer == null)
                {
                    response.SetFail(BaseResponse.ErrorCodeEnum.UserNotFound);
                    return(response);
                }
                response.Manufacturers    = new ManufacturerViewModel[1];
                response.Manufacturers[0] = manufacturer.ToModel();
            }
            catch (Exception e)
            {
                response.SetFail(e);
                _logger.LogError(e, e.Message, request);
            }
            return(response);
        }
        public async Task <IActionResult> Get([FromBody] ManufacturerGetRequest request)
        {
            try
            {
                if (String.IsNullOrEmpty(request.Name) && String.IsNullOrEmpty(request.Description))
                {
                    var response = await _manufacturerAppService.GetAll(request);

                    return(Json(response));
                }
                else
                {
                    var response = await _manufacturerAppService.Search(request);

                    return(Json(response));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e, Common.Common.GetMethodName());
                throw;
            }
        }
Exemple #5
0
        public async Task <RManufacturer[]> Search(ManufacturerGetRequest request)
        {
            RefSqlPaging p = new RefSqlPaging(request.PageIndex, request.PageSize);

            return(await _manufacturerRepository.Search(request.Name, 0, p));
        }
Exemple #6
0
 public async Task <RManufacturer[]> GetAll(ManufacturerGetRequest request)
 {
     return(await _manufacturerRepository.GetAll());
 }