Ejemplo n.º 1
0
    // POST api/<controller>
    public void Post([FromBody] ProductDto product) 
    {
      var context = new CallerContextDto()
      {
        DataSource = "ProductController"
      };

      if (!context.Rights.HasFlag(Rights.Write))
      {
        throw new AccessViolationException(); 
      }

      _productService.SendToBus(context, product);
    }
Ejemplo n.º 2
0
    // DELETE api/<controller>/5
    public void Delete(int id)
    {
      var context = new CallerContextDto()
      {
        DataSource = "ProductController"
      };
      
      if (!context.Rights.HasFlag(Rights.Delete))
      {
        throw new AccessViolationException(); 
      }

      _productService.GetProduct(context, id);
    }
Ejemplo n.º 3
0
    // GET api/<controller>/5
    public ProductDto Get(int id)
    {
      var context = new CallerContextDto()
      {
        DataSource = "ProductController"
      };

      if (!context.Rights.HasFlag(Rights.Read))
      {
       throw new AccessViolationException(); 
      }

      return _productService.GetProduct(context, id);
    }