public ActionResult AddProduct()
        {
            ViewBag.PageInfo = "ÜRÜN EKLE";
            ProductAddModel     addModel = new ProductAddModel();
            HttpResponseMessage result;

            result = WebApiRequestOperation.WebApiRequestOperationMethodForUser(SystemConstannts.WebApiDomainAddress, "api/Category/GetCategories", null);

            if (result.StatusCode == HttpStatusCode.OK)
            {
                string resultString = result.Content.ReadAsStringAsync().Result;
                if (resultString != "{\"Categories\":null}")
                {
                    GetCategoryListResponse getCategory = Newtonsoft.Json.JsonConvert.DeserializeObject <GetCategoryListResponse>(resultString);
                    if (getCategory.Code == 1)
                    {
                        addModel.Categories = getCategory.Categories;
                    }
                    else
                    {
                        addModel.Categories = null;
                    }
                }
            }

            result = WebApiRequestOperation.WebApiRequestOperationMethodForUser(SystemConstannts.WebApiDomainAddress, "api/Brand/GetBrands", null);
            if (result.StatusCode == HttpStatusCode.OK)
            {
                string resultString = result.Content.ReadAsStringAsync().Result;
                if (resultString != "{\"Brands\":null}")
                {
                    GetBrandListResponse getBrand = Newtonsoft.Json.JsonConvert.DeserializeObject <GetBrandListResponse>(resultString);
                    if (getBrand.Code == 1)
                    {
                        addModel.Brands = getBrand.Brands;
                    }
                    else
                    {
                        addModel.Brands = null;
                    }
                }
            }
            addModel.Product = null;
            return(View(addModel));
        }
示例#2
0
        public async Task <object> GetBrands()
        {
            GetBrandListResponse response = new GetBrandListResponse();

            try
            {
                List <Brand> brands = await _brandService.GetList();

                response.Brands = brands;
                if (brands != null)
                {
                    response.setError(Common.SystemConstants.SystemConstannts.ERROR_CODES.SUCCESS);
                }
                else
                {
                    response.setError(Common.SystemConstants.SystemConstannts.ERROR_CODES.NOTFOUND);
                }
            }
            catch
            {
                response.setError(Common.SystemConstants.SystemConstannts.ERROR_CODES.SYSTEMERROR);
            }
            return(response);
        }