// GET: /Article/Create public ActionResult Create() { //Load stores var storeResponse = new PluralStoreResponse(); var response = SuperZapatosAPI.CallGetAPI("services/GetStores/"); var items = new List <SelectListItem>(); if (response.IsSuccessStatusCode) { // Creating Json Request Object storeResponse = new JavaScriptSerializer().Deserialize <PluralStoreResponse>(response.Content.ReadAsStringAsync().Result); foreach (var item in storeResponse.stores) { SelectListItem newItem = new SelectListItem() { Text = item.name, Value = item.id.ToString() }; items.Add(newItem); } } ViewBag.Stores = items; return(View()); }
public ActionResult Edit([Bind(Include = "Id,Name,Address")] StoreModel storemodel) { if (ModelState.IsValid) { var response = SuperZapatosAPI.CallAPI("services/UpdateStore/", storemodel); return(RedirectToAction("Index")); } return(View(storemodel)); }
public ActionResult Create([Bind(Include = "name, description, price, total_in_shelf, total_in_vault, store_id")] ArticleModel articlemodel) { if (ModelState.IsValid) { var response = SuperZapatosAPI.CallAPI("services/CreateArticle/", articlemodel); return(RedirectToAction("Index")); } return(View(articlemodel)); }
// GET: Store public ActionResult Index() { var storeResponse = new PluralStoreResponse(); var response = SuperZapatosAPI.CallGetAPI("services/GetStores/"); if (response.IsSuccessStatusCode) { // Creating Json Request Object storeResponse = new JavaScriptSerializer().Deserialize <PluralStoreResponse>(response.Content.ReadAsStringAsync().Result); } return(View(storeResponse.stores)); }
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)); }
// GET: /Article/Edit/ public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index")); } var articleResponse = new SingularArticleResponse(); var result = SuperZapatosAPI.CallGetAPI("services/GetArticleById/", id.ToString()); if (result.IsSuccessStatusCode) { // Creating Json Request Object articleResponse = new JavaScriptSerializer().Deserialize <SingularArticleResponse>(result.Content.ReadAsStringAsync().Result); } //Load stores var storesResponse = new PluralStoreResponse(); var response = SuperZapatosAPI.CallGetAPI("services/GetStores/"); var items = new List <SelectListItem>(); if (response.IsSuccessStatusCode) { // Creating Json Request Object storesResponse = new JavaScriptSerializer().Deserialize <PluralStoreResponse>(response.Content.ReadAsStringAsync().Result); foreach (var item in storesResponse.stores) { SelectListItem newItem = new SelectListItem() { Text = item.name, Value = item.id.ToString() }; items.Add(newItem); } } ViewBag.Stores = items; return(View(articleResponse.article)); }