private JsonRespondBody DishinfoMethod(JsonRequestBody json)
{
aspnetuser user = DataManager.User.GetUserByToken(json.Token);
if (user == null)
{
return new JsonRespondBody { Error = "Invalid token", Status = "error" };
}
if (!json.Parameters.ContainsKey("Id_Dish"))
{
return new JsonRespondBody { Error = "Id_Dish is required", Status = "error" };
}
int dish_id = 0;
try
{
dish_id = Convert.ToInt32(json.Parameters["Id_Dish"]);
}
catch
{
return new JsonRespondBody { Error = "Invalid parameters", Status = "error" };
}
//генерация ответа
dish d = DataManager.Dish.GetDishById(dish_id);
if (d == null)
{
return new JsonRespondBody { Error = "Dish not found", Status = "warning" };
}
string address = string.Format("{0}://{1}", Request.Url.Scheme, Request.Url.Authority);
DishSerealizerBody res = new DishSerealizerBody
{
Description = d.Description,
Id = d.Id_Dish,
Ingridients = d.Ingridient,
Name = d.Name,
Price = d.Price,
PriceWithIngridients = d.PriceWithIngridient,
Type = d.dishtype.Name,
Image = address + d.ImageUrl
};
JsonRespondBody result = new JsonRespondBody
{
Result = res,
Status = "OK"
};
return result;
}