[ActionName("PostBody")] // http://localhost:5001/apoi/CategoryBinderAPI/PostBody public async Task <IActionResult> PostFromBody([FromBody] Categories input) { if (ModelState.IsValid) { var result = await catRepository.CreateAsync(input); return(Ok(result)); } return(BadRequest(ModelState)); }
public async Task <IActionResult> Create(Categories data) { //try //{ if (ModelState.IsValid) { if (data.BasePrice < 0) { throw new Exception("Base Price Cannot be -ve"); } data = await catRepository.CreateAsync(data); return(RedirectToAction("Index")); } return(View(data)); //} //catch (Exception ex) //{ // return View("Error", new ErrorViewModel() // { // ControllerName = this.RouteData.Values["controller"].ToString(), // ActionName = this.RouteData.Values["action"].ToString(), // ErrorMessage =ex.Message // }); //} }
public async Task <IActionResult> Create(Products data) { if (ModelState.IsValid) { data = await prdRepository.CreateAsync(data); return(RedirectToAction("Index")); } ViewData["CategoryRowId"] = catRepository.GetDataAsync().Result; return(View(data)); }
public async Task <IActionResult> Post(Categories input) { if (ModelState.IsValid) { if (input.BasePrice < 0) { throw new Exception("BasePrice cannoty be -Ve"); } var result = await catRepository.CreateAsync(input); return(Ok(result)); } return(BadRequest(ModelState)); }