I am working on the following tables :
BadgesGroup
table: contains a list of badges that are grouped together -> group A have badge 1 and 2 , Gruop B have badge 3 and 4 ...etc also contain information such as group logoBadges
table: contains information about a specific badge such as title and descriptionCustomerBadges
table: contains the progress of each badge and to which customer it belong to
Following this tutorial : https://blogs.msdn.microsoft.com/azuremobile/2014/05/27/retrieving-data-from-1n-relationship-using-net-backend-azure-mobile-services/
I managed to work it out successfully and retrieve all information of a given group with one API request.
Example :
[
{
"deleted": false,
"updatedAt": null,
"createdAt": "2019-07-07T17:47:32.043Z",
"version": "AAAAAAAAJyQ=",
"id": "4CD03F1F-BDB2-47BC-9084-35B5DF7E1530",
"levels": 4,
"logo": "img.png",
"badges": [
{
"customerBadge": [
{
"progress": 1,
"id": "037EC616-A17C-4E89-B4F5-F4DE960AB3B5",
"version": "AAAAAAAAJz4=",
"createdAt": "2019-07-07T17:51:21.253Z",
"updatedAt": null,
"deleted": false
}
],
"title": "Noob",
"description": "redeem 1",
"currentLevel": 1,
"id": "0F63CFD2-6679-4D25-AB40-280003555676",
"version": "AAAAAAAAJyw=",
"createdAt": "2019-07-07T17:48:24.429Z",
"updatedAt": null,
"deleted": false
},
{
"customerBadge": [
{
"progress": 4,
"id": "545B769C-FCA1-4C5D-BB5A-4D31BD724340",
"version": "AAAAAAAAJ0Q=",
"createdAt": "2019-07-07T17:51:32.035Z",
"updatedAt": null,
"deleted": false
}
],
"title": "King",
"description": "redeem 4",
"currentLevel": 4,
"id": "39E8E825-9196-43BC-890A-7E7833615818",
"version": "AAAAAAAAJy0=",
"createdAt": "2019-07-07T17:49:45.13Z",
"updatedAt": null,
"deleted": false
},
{
"customerBadge": [
{
"progress": 3,
"id": "24E30749-78A5-4AA9-B097-073C8E7162FD",
"version": "AAAAAAAAJ0Y=",
"createdAt": "2019-07-07T17:51:40.076Z",
"updatedAt": null,
"deleted": false
}
],
"title": "Master",
"description": "Redeem 3",
"currentLevel": 3,
"id": "935FE343-A6EC-43DD-8E50-6461A69CC757",
"version": "AAAAAAAAJy4=",
"createdAt": "2019-07-07T17:49:22.741Z",
"updatedAt": null,
"deleted": false
},
{
"customerBadge": [
{
"progress": 2,
"id": "0723DB30-D7AF-41C5-8E6F-3B3A174805B9",
"version": "AAAAAAAAJ0U=",
"createdAt": "2019-07-07T17:51:15.04Z",
"updatedAt": null,
"deleted": false
}
],
"title": "Pro",
"description": "redeem 2",
"currentLevel": 2,
"id": "9E169884-11FC-4893-8465-3D4792CCEEBC",
"version": "AAAAAAAAJy8=",
"createdAt": "2019-07-07T17:49:05.011Z",
"updatedAt": null,
"deleted": false
}
]
},
{
"deleted": false,
"updatedAt": null,
"createdAt": "2019-07-07T17:47:53.101Z",
"version": "AAAAAAAAJyU=",
"id": "602BBB5D-06D4-4685-AB65-5514CA73884B",
"levels": 2,
"logo": "img2.png",
"badges": [
{
"customerBadge": [
{
"progress": 22,
"id": "C236C1AB-37DC-47C9-B0CF-2825A916E77E",
"version": "AAAAAAAAJ0g=",
"createdAt": "2019-07-07T17:51:26.765Z",
"updatedAt": null,
"deleted": false
}
],
"title": "Old",
"description": "buy 4",
"currentLevel": 2,
"id": "74818583-1BC3-4FC5-81A2-4846C752CC8E",
"version": "AAAAAAAAJzE=",
"createdAt": "2019-07-07T17:50:23.947Z",
"updatedAt": null,
"deleted": false
},
{
"customerBadge": [
{
"progress": 11,
"id": "6D541809-1775-49AA-83AE-F434E3CC0E08",
"version": "AAAAAAAAJ0c=",
"createdAt": "2019-07-07T17:51:07.33Z",
"updatedAt": null,
"deleted": false
}
],
"title": "New",
"description": "buy 1",
"currentLevel": 1,
"id": "81DE6DFB-D6F8-49D6-A62B-3F5AF018DE40",
"version": "AAAAAAAAJzA=",
"createdAt": "2019-07-07T17:50:09.621Z",
"updatedAt": null,
"deleted": false
}
]
}
]
These are my models in the Azure backend using C# and one Azure mobile controller named AchievementGroupController
auto generated :
public class AchievementGroup : EntityData
{
public AchievementGroup()
{
Badges = new List<Badge>();
}
public string Logo { get; set; }
public int Levels { get; set; }
public virtual ICollection<Badge> Badges { get; set; }
}
public class Badge : EntityData
{
public Badge()
{
CustomerBadge = new List<CustomerBadge>();
}
public string Title { get; set; }
public string description { get; set; }
public int CurrentLevel { get; set; }
public virtual AchievementGroup AchievementGroup { get; set; }
public virtual ICollection<CustomerBadge> CustomerBadge { get; set; }
}
public class CustomerBadge : EntityData
{
public int Progress { get; set; }
[Required]
public virtual Badge Badge { get; set; }
}
Now what my issue is I can not distinguish which customer has which progress.
I want to tell the API give me All badge groups and their progress for this given customer.