private JsonRespondBody OffersMethod(JsonRequestBody json) { int Limit = 20; int Page = 0; string Search = ""; int City = 0; string category = ""; int minPrice = -1; int maxPrice = -1; aspnetuser user = DataManager.User.GetUserByToken(json.Token); if (user == null) { return new JsonRespondBody { Error = "Invalid token", Status = "error" }; } if (json.Parameters.ContainsKey("Limit")) { try { Limit = Convert.ToInt32(json.Parameters["Limit"]); Limit = Limit < 1 ? 1 : Limit; } catch { } } if (json.Parameters.ContainsKey("Page")) { try { Page = Convert.ToInt32(json.Parameters["Page"]); Page = Page < 0 ? 0 : Page; } catch { } } if (json.Parameters.ContainsKey("Search")) { Search = json.Parameters["Search"]; } if (json.Parameters.ContainsKey("City")) { try { City = Convert.ToInt32(json.Parameters["City"]); } catch { } } if (json.Parameters.ContainsKey("Category")) { try { int b; if (Int32.TryParse(json.Parameters["Category"], out b)) { category = json.Parameters["Category"] + ";"; } } catch { } } if (json.Parameters.ContainsKey("MinPrice")) { try { minPrice = Convert.ToInt32(json.Parameters["MinPrice"]); } catch { } } if (json.Parameters.ContainsKey("MaxPrice")) { try { maxPrice = Convert.ToInt32(json.Parameters["MaxPrice"]); } catch { } } //генерация ответа string address = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority); int count = 0; IEnumerable<dish> list = DataManager.Dish.GetDishList(Page, Limit, ref count, Search, City, category, false, false, minPrice, maxPrice); List<DishSerealizerBody> res = new List<DishSerealizerBody>(); foreach (var item in list) { res.Add(new DishSerealizerBody { Description = item.Description, Id = item.Id_Dish, Ingridients = item.Ingridient, Name = item.Name, Price = item.Price, PriceWithIngridients = item.PriceWithIngridient, Type = item.dishtype.Name, Image = address + item.ImageUrl }); } OfferSerealizerBody r = new OfferSerealizerBody { CurrentPage = Page, Limit = Limit, List = res, }; JsonRespondBody result = new JsonRespondBody { Status = "OK", Result = r }; return result; }