Ejemplo n.º 1
0
 public async Task <ActionResult <bool> > DeleteProduct([FromBody] Product product)
 {
     try
     {
         if (!await User.IsPlaceProviderAdmin(userRepository, placeProviderRepository))
         {
             throw new Exception(localizer[Resources.Controllers_AdminController.Only_admin_is_allowed_to_invite_other_users].Value);
         }
         return(Ok(await placeProviderRepository.DeleteProduct(User.GetPlaceProvider(), product)));
     }
     catch (ArgumentException exc)
     {
         logger.LogError(exc.Message);
         return(BadRequest(new ProblemDetails()
         {
             Detail = exc.Message
         }));
     }
     catch (Exception exc)
     {
         logger.LogError(exc, exc.Message);
         return(BadRequest(new ProblemDetails()
         {
             Detail = exc.Message
         }));
     }
 }