public IHttpActionResult Get(int id) { IHttpActionResult ret; PTCViewModel vm = new PTCViewModel(); vm.Get(id); if (vm.Entity != null) { ret = Ok(vm.Entity); } else if (vm.LastException != null) { ret = BadRequest(vm.Message); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Get() { IHttpActionResult ret; PTCViewModel vm = new PTCViewModel(); //throw new ApplicationException("Error"); to check error vm.Get(); if (vm.Products.Count() > 0) { ret = Ok(vm.Products); } else if (vm.LastException != null) { ret = BadRequest(vm.Message); } else { ret = NotFound(); } return(ret); }