// POST api/todoapi // Saves in the db a new Todo item associated to the current caller public void Post(Todo todo) { VerifyScope(); todo.Owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; db.Todoes.Add(todo); db.SaveChanges(); }
public void Onboard([FromBody] string name) { // here "name" is just a placeholder for the real data your app would require from the caller // if (MyCustomOnboardingDataValidation(name)) string upn = ClaimsPrincipal.Current.FindFirst(ClaimTypes.Name).Value; string tenantID = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value; if (db.Users.FirstOrDefault(a => (a.UPN == upn) && (a.TenantID == tenantID)) == null) { // add the caller to the collection of valid users db.Users.Add(new User { UPN = upn, TenantID = tenantID }); } db.SaveChanges(); }