Exemple #1
0
        public IHttpActionResult GetInventory([FromUri] int id)
        {
            Exception          ex     = null;
            InventoryViewModel result = null;

            try {
                var inventory = _dataProvider.GetEntity <Inventory>(id);
                result = new InventoryViewModel(inventory);

                result.AddLink(new Link(Request.RequestUri, HttpMethod.Get, RelValues.Self, ActionValues.Refresh, "Inventories/" + id));
                result.AddLink(new Link(Request.RequestUri, HttpMethod.Put, RelValues.Self, ActionValues.Save, "Inventories/" + id));
                result.AddLink(new Link(Request.RequestUri, HttpMethod.Delete, RelValues.Self, ActionValues.Delete, "Inventories/" + id));
            } catch (Exception e) {
                ex = e;
            }

            return(GetHttpActionResult(result, ex));
        }