public async Task <IActionResult> Add([FromBody] ManufacturerMappingAddRequest request)
 {
     try
     {
         ManufacturerMappingAddResponse response = new ManufacturerMappingAddResponse();
         var results = ManufacturerCategoryMappingAddRequestValidator.ValidateModel(request);
         if (results.IsValid)
         {
             results = ManufacturerCategoryMappingAddRequestValidator.ValidateModel(request);
             if (results.IsValid)
             {
                 response = await _manufacturerCategoryMappingAppService.Add(request);
             }
             else
             {
                 response.SetFail(results.Errors.Select(p => p.ToString()));
             }
         }
         else
         {
             response.SetFail(results.Errors.Select(p => p.ToString()));
         }
         return(Json(response));
     }
     catch (Exception e)
     {
         _logger.LogError(e, Common.Common.GetMethodName(), request);
         throw;
     }
 }
Exemplo n.º 2
0
        public async Task <ManufacturerMappingAddResponse> Add(ManufacturerMappingAddRequest request)
        {
            ManufacturerMappingAddResponse response = new ManufacturerMappingAddResponse();

            try
            {
                var command = request.ToAddCommand();

                var result = await _manufacturerCategoryMappingService.SendCommand(command);

                if (result.IsSucess)
                {
                    response.SetSucess();
                }
                else
                {
                    response.SetFail(result.Message);
                }
            }
            catch (Exception e)
            {
                response.SetFail(e);
                _logger.LogError(e, e.Message, request);
            }
            return(response);
        }