Пример #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());
        }
Пример #2
0
        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));
        }
Пример #3
0
        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));
        }
Пример #4
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));
        }
Пример #5
0
        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"));
        }
Пример #6
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));
        }
Пример #7
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));
        }