public IHttpActionResult Put(int id, Product product) { IHttpActionResult ret = null; PTCViewModel vm = new PTCViewModel(); vm.Entity = product; vm.PageMode = PageConstants.EDIT; vm.Save(); if (vm.IsValid) { ret = Ok(product); } else if (vm.Messages.Count > 0) { ret = BadRequest(ConvertToModelState(vm.Messages)); } else { ret = NotFound(); } return(ret); }
public ActionResult Index() { PTCViewModel vm = new PTCViewModel(); vm.HandleRequest(); return(View(vm)); }
public IHttpActionResult Put(int id, Product product) { IHttpActionResult ret = null; PTCViewModel vm = new PTCViewModel(); if (product != null) { vm.Entity = product; vm.PageMode = PDSAPageModeEnum.Edit; vm.Save(); if (vm.IsValid) { ret = Ok(vm.Entity); } else { if (vm.Messages.Count > 0) { ret = BadRequest(ConvertToModelState(vm.Messages)); } else if (vm.LastException != null) { ret = BadRequest(vm.Message); } } } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Post(Product product) { IHttpActionResult ret = null; PTCViewModel vm = new PTCViewModel(); vm.Entity = product; vm.PageMode = PageConstants.ADD; vm.Save(); if (vm.IsValid) { ret = Created <Product>( Request.RequestUri + product.ProductId.ToString(), product); } else if (vm.Messages.Count > 0) { ret = BadRequest(ConvertToModelState(vm.Messages)); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Put(int id, Product product) { var vm = new PTCViewModel(); if (product == null) { return(NotFound()); } vm.Entity = product; vm.PageMode = PDSAPageModeEnum.Edit; vm.Save(); if (!vm.IsValid) { if (vm.Messages.Count > 0) { return(BadRequest(ConvertToModelState(vm.Messages))); } else if (vm.LastException != null) { return(BadRequest(vm.Message)); } } return(Ok(vm.Entity)); }
public IHttpActionResult Post(Product product) { IHttpActionResult ret = null; var vm = new PTCViewModel(); if (product != null) { vm.Entity = product; vm.PageMode = PDSAPageModeEnum.Add; vm.Save(); if (vm.IsValid) { return(Created(Request.RequestUri + vm.Entity.ProductId.ToString(), vm.Entity)); } else { if (vm.Messages.Count > 0) { return(BadRequest(ConvertToModelState(vm.Messages))); } else { return(BadRequest(vm.Message)); } } } return(NotFound()); }
public IHttpActionResult SearchPriceAndMake(ProductSearch searchEntity) { IHttpActionResult ret = null; PTCViewModel vm = new PTCViewModel(); //Search for Products vm.SearchEntity = searchEntity; vm.SearchPriceAndMake(); var priceRange = vm.ProductsMaxPrice.Intersect(vm.ProductsMinPrice); var makeAndPriceRange = priceRange.Intersect(vm.Products); vm.Products = makeAndPriceRange.ToList(); if (vm.Products.Count > 0) { ret = Ok(vm.Products); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Delete(int id) { var vm = new PTCViewModel(); vm.Delete(id); if (vm.LastException != null) { return(BadRequest(vm.Message)); } return(Ok(vm.Entity)); }
public ActionResult Index(PTCViewModel vm) { vm.HandleRequest(); if (vm.IsValid) { ModelState.Clear(); } else { ModelState.Merge(vm.Messages); } return(View(vm)); }
public IHttpActionResult Get() { var vm = new PTCViewModel(); vm.LoadSearchCategories(); if (vm.SearchCategories.Count > 0) { return(Ok(vm.SearchCategories)); } else { return(NotFound()); } }
public IHttpActionResult Search([FromBody] ProductSearch search) { var vm = new PTCViewModel(); vm.SearchEntity = search; vm.Search(); if (vm.LastException != null) { return(BadRequest(vm.Message)); } else { return(Ok(vm.Products)); } }
public ActionResult Product(PTCViewModel vm) { vm.HandleRequest(); // If everything is OK, update the model state on the page if (vm.IsValid) { ModelState.Clear(); } else { ModelState.Merge(vm.Messages); } return(View(vm)); }
public IHttpActionResult GetSearchCategories() { IHttpActionResult ret = null; PTCViewModel vm = new PTCViewModel(); vm.LoadSearchCategories(); if (vm.SearchCategories.Count > 0) { ret = Ok(vm.SearchCategories); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Delete(int id) { IHttpActionResult ret; PTCViewModel vm = new PTCViewModel(); vm.Delete(id); if (vm.LastException != null) { ret = BadRequest(vm.Message); } else { ret = Ok(vm.Entity); } return(ret); }
public IHttpActionResult Get() { var vm = new PTCViewModel(); vm.LoadCategories(); if (vm.Categories.Count > 0) { return(Ok(vm.Categories)); } else if (vm.LastException != null) { return(BadRequest(vm.Message)); } return(NotFound()); }
// GET api/<controller> public IHttpActionResult Get() { IHttpActionResult ret = null; PTCViewModel vm = new PTCViewModel(); vm.Get(); if (vm.Products.Count > 0) { ret = Ok(vm.Products); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Get(int id) { IHttpActionResult ret; Product prod = new Product(); PTCViewModel vm = new PTCViewModel(); prod = vm.Get(id); if (prod != null) { ret = Ok(prod); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Get(int id) { var vm = new PTCViewModel(); vm.Get(id); if (vm.Entity != null) { return(Ok(vm.Entity)); } else if (vm.LastException != null) { return(BadRequest(vm.Message)); } return(NotFound()); }
public IHttpActionResult Search(ProductSearch searchEntity) { IHttpActionResult ret = null; var vm = new PTCViewModel(); vm.SearchEntity = searchEntity; vm.Search(); if (vm.Products.Count > 0) { ret = Ok(vm.Products); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Get(int id) { IHttpActionResult ret = null; var vm = new PTCViewModel(); var product = vm.Get(id); if (product != null) { ret = Ok(product); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Delete(int id) { IHttpActionResult ret = null; PTCViewModel vm = new PTCViewModel(); vm.Entity = vm.Get(id); if (vm.Entity.ProductId > 0) { vm.Delete(id); ret = Ok(true); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Get() { IHttpActionResult ret = null; var vm = new PTCViewModel(); //throw new ApplicationException("Error in the Get() method"); vm.Get(); if (vm.Products.Count > 0) { ret = Ok(vm.Products); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Put(int id, Product product) { IHttpActionResult ret = null; var vm = new PTCViewModel(); vm.Entity = product; vm.PageMode = PageConstants.EDIT; vm.Save(); if (vm.IsValid) { ret = Ok(product); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Post(Product product) { IHttpActionResult ret = null; var vm = new PTCViewModel(); vm.Entity = product; vm.PageMode = PageConstants.ADD; vm.Save(); if (vm.IsValid) { ret = Created(Request.RequestUri + product.ProductId.ToString(), product); } else { ret = NotFound(); } return(ret); }
// GET api/<controller> public IHttpActionResult Get() { IHttpActionResult ret; PTCViewModel vm = new PTCViewModel(); 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); }
public IHttpActionResult GetSearchCategories() { IHttpActionResult ret; PTCViewModel vm = new PTCViewModel(); vm.LoadSearchCategories(); if (vm.SearchCategories.Count() > 0) { ret = Ok(vm.SearchCategories); } else if (vm.LastException != null) { ret = BadRequest(vm.Message); } else { ret = NotFound(); } return(ret); }
public IHttpActionResult Delete(int id) { IHttpActionResult ret = null; PTCViewModel vm = new PTCViewModel(); // Get the product vm.Entity = vm.Get(id); // Did we find the product? if (vm.Entity.ProductId > 0) { // Delete the product vm.Delete(id); ret = Ok(true); } else { ret = NotFound(); } return(ret); }