public async Task <object> GetCategories() { GetCategoryListResponse response = new GetCategoryListResponse(); try { List <Category> categories = await _categoryService.GetList(); response.Categories = categories; if (categories == null) { response.setError(Common.SystemConstants.SystemConstannts.ERROR_CODES.NOTFOUND); } else { response.setError(Common.SystemConstants.SystemConstannts.ERROR_CODES.SUCCESS); } } catch { response.setError(Common.SystemConstants.SystemConstannts.ERROR_CODES.SYSTEMERROR); } return(response); }
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)); }
public static GetCategoryListResponse Unmarshall(UnmarshallerContext context) { GetCategoryListResponse getCategoryListResponse = new GetCategoryListResponse(); getCategoryListResponse.HttpResponse = context.HttpResponse; getCategoryListResponse.RequestId = context.StringValue("GetCategoryList.RequestId"); List <GetCategoryListResponse.GetCategoryList_Category> getCategoryListResponse_categoryList = new List <GetCategoryListResponse.GetCategoryList_Category>(); for (int i = 0; i < context.Length("GetCategoryList.CategoryList.Length"); i++) { GetCategoryListResponse.GetCategoryList_Category category = new GetCategoryListResponse.GetCategoryList_Category(); category.CateId = context.StringValue("GetCategoryList.CategoryList[" + i + "].CateId"); category.CateName = context.StringValue("GetCategoryList.CategoryList[" + i + "].CateName"); category.ParentId = context.StringValue("GetCategoryList.CategoryList[" + i + "].ParentId"); category.Level = context.StringValue("GetCategoryList.CategoryList[" + i + "].Level"); getCategoryListResponse_categoryList.Add(category); } getCategoryListResponse.CategoryList = getCategoryListResponse_categoryList; return(getCategoryListResponse); }