Beispiel #1
0
        // 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());
        }
Beispiel #2
0
        // 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));
        }
Beispiel #3
0
        // 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));
        }
Beispiel #4
0
        // 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));
        }