Почтальон и прямой URL-ответ
"MenuId": 2010,
"KitchenId": 2005,
"Categoryid": 1,
"CategoryName": "Starters",
"SubCategoryId": 1,
"SubCategoryName": "Veg Starters",
"Name": "Paneer Kabab",
"Description": "Paneer fried",
"ImageURL": "noimage.png",
"Foodtype": 1,
"NetPrice": 70.00,
"NetGST": 3.50,
"NetTotal": 83.50,
"ListPrice": 84.00,
"ListGST": 4.20,
"ListTotal": 99.20,
"PackingCharge": 11.00,
"Discount": null,
"TotalOrders": 0.00,
"Ratings": null,
"MenuStatus": 1,
"VegTypeId": 1,
"GetButton_no": [
{
**"ButtonNo_No": 99.20**
}
],
Консоль браузера
{ "MenuId": 2010,
"KitchenId": 2005,
"Categoryid": 1,
"CategoryName": "Starters",
"SubCategoryId": 1,
"SubCategoryName": "Veg Starters",
"Name": "Paneer Kabab",
"Description": "Paneer fried",
"ImageURL": "noimage.png",
"Foodtype": 1,
"NetPrice": 70.00,
"NetGST": 3.50,
"NetTotal": 83.50,
"ListPrice": 84.00,
"ListGST": 4.20,
"ListTotal": 99.20,
"PackingCharge": 11.00,
"Discount": null,
"TotalOrders": 0.00,
"Ratings": null,
"MenuStatus": 1,
"VegTypeId": 1,
"GetButton_no": [
{
**"ButtonNo_No": null**
}
],
}
Почему один и тот же API ведет себя по-разному, я Я использую Entity Framework для этого.
public IEnumerable<KitchenMenu_CategoryModel> GetKitchenMenubyKitchennew(int kid,string Username)
{
var result = db.tblKitchens.Where(x => x.Id == kid).Select(x => new KitchenMenu_CategoryModel
{
KitchenId = x.Id,
KitchenName = x.KitchenName,
KitchenType = x.KitchenType,
Area = x.Area,
Address1 = x.Address1,
Address2 = x.Address2,
//CId = x.CityId,
Pincode = x.Pincode,
Email = x.Email,
Website = x.Website,
Landline = x.Landline,
Halal = x.Halal,
Category = x.Category,
Branches = x.Branches,
AvgCost = x.AvgCost,
Fssai = x.Fssai,
FssaiPath = x.FssaiPath,
RegisterStatus = x.RegisterStatus,
Logo = db.tblKitchenMedias.Where(r => r.KitchenId == x.Id).Select(r => r).FirstOrDefault().Logo,
Banner = db.tblKitchenMedias.Where(s => s.KitchenId == x.Id).Select(s => s).FirstOrDefault().Banner,
GetCategory = db.tblGetCategories.Where(y => y.Kitchenid == x.Id).Select(y => new CategoryModel
{
CategoryId = y.Categoryid,
Kitchenid = y.Kitchenid,
CategoryName = y.tblCategory.CategoryName,
SubCateogry = db.tblGetSubCategories.Where(z => z.Categoryid == y.Categoryid && z.Kitchenid == y.Kitchenid).Select(z => new SubCategoryModel
{
Categoryid = z.Categoryid,
SubCategoryName = z.tblSubCategory.SubCategoryName,
Kitchenid = z.Kitchenid,
GetMenu = db.tblMenus.Where(a => a.SubCategoryId == z.SubCategoryid && a.KitchenId == z.Kitchenid).Select(a => new MenuModel
{
MenuId = a.MenuId,
Name = a.Name,
Description = a.Description,
Discount = a.Discount,
ImageURL = a.ImageURL,
ListGST = a.ListGST,
ListPrice = a.ListPrice,
ListTotal = a.ListTotal,
NetGST = a.NetGST,
NetPrice = a.NetPrice,
TotalOrders = a.TotalOrders,
KitchenId = a.KitchenId,
SubCategoryId = a.SubCategoryId,
MenuStatus = a.MenuStatus,
NetTotal = a.NetTotal,
VegTypeId = a.VegTypeId,
Categoryid = a.Categoryid,
CategoryName = a.tblCategory.CategoryName,
SubCategoryName = a.tblSubCategory.SubCategoryName,
Ratings = a.Ratings,
Foodtype = a.Foodtype,
PackingCharge = a.PackingCharge,
GetButton_no =db.tblcarts.Where(d => d.Username == Username && d.KitchenId == kid && d.MenuId == a.MenuId).Select(d => new ButtonModel
{
ButtonNo_No =d.TotalPrice,
}
).ToList(),
//ButtonNo_No = db.tblcarts.Where(d => d.Username == Username && d.KitchenId == a.KitchenId && d.MenuId == a.MenuId).Select(d => d).FirstOrDefault().Quantity,
//Button_No =db.spCountCartButton(Username,a.KitchenId,a.MenuId).Select(d=>d).FirstOrDefault(),
GetMenuAttribute = db.tblMenuAttributes.Where(b => b.Menuid == a.MenuId).Select(b => new MenuAttributeModel
{
MenuAttributeId = b.MenuAttributeId,
Menuid = b.Menuid,
AttributeType = b.AttributeType,
MenuAttribute = b.MenuAttribute,
MenuDescription = b.MenuDescription,
NetPrice = b.NetPrice,
NetGST = b.NetGST,
NetTotal = b.NetTotal,
ListPrice = b.ListPrice,
ListGST = b.ListGST,
ListTotal = b.ListTotal,
PackingCharge = b.PackingCharge,
}
).ToList(),
}
).ToList(),
}
).ToList(),
}
).ToList(),
}
).ToList();
return result;
}
- Контроллер API
[Route ("api / GetMenuBykidnew")] [HttpGet] publi c HttpResponseMessage GetMenuBykid (int kid, string Имя пользователя) {// var data = new List ();
ApiBusiness ApiBus = new ApiBusiness();
var result = ApiBus.GetKitchenMenubyKitchennew(kid, Username);
return new HttpResponseMessage()
{
Content = new StringContent(JArray.FromObject(result).ToString(), Encoding.UTF8, "application/json")
};
}
Ответ очень странный, получая разные ответы в консоли браузера и почтальоне