public IHttpActionResult GetStoreById(string id) { int idInt = 0; var response = new SingularStoreResponse(); var result = new StoreDTO(); try { // Validate request if (string.IsNullOrEmpty(id) || !int.TryParse(id, out idInt)) { return(Ok(ResponseHandler.Error(400))); } result = ContextBehaviours.GetStoreById(idInt); // Validate if find record if (result == null) { return(Ok(ResponseHandler.Error(404))); } // Prepare success response response.store = result; response.success = true; return(Ok(response)); } catch (Exception ex) { return(Ok(ResponseHandler.Error(500))); } }
public ActionResult DeleteConfirmed(int?id) { var storeResponse = new SingularStoreResponse(); var idModel = new IdModel(); idModel.id = id.ToString(); var response = SuperZapatosAPI.CallAPI("services/DeleteStore/", idModel); if (response.IsSuccessStatusCode) { // Creating Json Request Object storeResponse = new JavaScriptSerializer().Deserialize <SingularStoreResponse>(response.Content.ReadAsStringAsync().Result); } return(RedirectToAction("Index")); }
// GET: /Stores/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(RedirectToAction("Index")); } var storeResponse = new SingularStoreResponse(); var response = SuperZapatosAPI.CallGetAPI("services/GetStoreById/", id.ToString()); if (response.IsSuccessStatusCode) { // Creating Json Request Object storeResponse = new JavaScriptSerializer().Deserialize <SingularStoreResponse>(response.Content.ReadAsStringAsync().Result); } return(View(storeResponse.store)); }
public IHttpActionResult CreateStore([FromBody] StoreDTO store) { var response = new SingularStoreResponse(); try { ContextBehaviours.CreateStore(store); // Prepare success response response.store = store; response.success = true; return(Ok(response)); } catch (Exception ex) { return(Ok(ResponseHandler.Error(500))); } }
public IHttpActionResult DeleteStore([FromBody] IdModels id) { int idInt = 0; var response = new SingularStoreResponse(); try { // Validate request if (string.IsNullOrEmpty(id.id) || !int.TryParse(id.id, out idInt)) { return(Ok(ResponseHandler.Error(400))); } var result = ContextBehaviours.DeleteStore(idInt); // Prepare success response response.store = result; response.success = true; return(Ok(response)); } catch (Exception ex) { return(Ok(ResponseHandler.Error(500))); } }