Esempio n. 1
0
        public IActionResult Update(int key, DealerApplicationConfigurationViewModel data)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(data.DealerId) || string.IsNullOrWhiteSpace(data.Application))
                {
                    return(new BadRequestObjectResult("Invalid data"));
                }

                var defaultLocations = _configuration.GetSection("ApplicationName").Get <List <string> >();
                if (key != data.DealerApplicationConfigurationKey)
                {
                    return(new BadRequestObjectResult("The key does not match"));
                }
                var dataDto = _mapper.Map <DealerApplicationConfigurationDTO>(data);
                var result  = _dealerAppConfigService.Update(dataDto);
                if (!string.IsNullOrEmpty(result))
                {
                    return(new BadRequestObjectResult(result));
                }
                return(new OkResult());
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message) && ex.InnerException.Message.Contains("permission was denied"))
                {
                    return(new BadRequestObjectResult("You don't have permission to do this"));
                }
                return(new BadRequestObjectResult(ex.Message));
            }
        }
Esempio n. 2
0
 public IActionResult Add(DealerApplicationConfigurationViewModel data)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(data.DealerId) || string.IsNullOrWhiteSpace(data.Application))
         {
             return(new BadRequestObjectResult("Invalid data"));
         }
         var dataDto = _mapper.Map <DealerApplicationConfigurationDTO>(data);
         var result  = _dealerAppConfigService.Add(dataDto);
         if (!string.IsNullOrEmpty(result))
         {
             return(new BadRequestObjectResult(result));
         }
         return(new OkResult());
     }
     catch (Exception ex)
     {
         if (ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message) && ex.InnerException.Message.Contains("permission was denied"))
         {
             return(new BadRequestObjectResult("You don't have permission to do this"));
         }
         return(new BadRequestObjectResult(ex.Message));
     }
 }