Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Delete(int id)
        {
            try
            {
                if (!await authorization.UserCanDeleteProduct(User.Identity.GetUserName(), id))
                {
                    return(Unauthorized());
                }

                await crudOnFavorites.DeleteProductFromAllUsers(id);

                int idOfProduct = await crudOnProducts.DeleteProduct(id);

                return(Ok(idOfProduct));
            }
            catch (Exception ex)
            {
                return(throwExceptionToUser.Throw(ex));
            }
        }