public async Task <JObject> Post(Apartment ap) { var userId = User.FindFirst("sub")?.Value; _logger.LogInformation("Adding new apartment owned by " + User.Identity.Name); var phoneNum = TrueHomeContext.getPhoneNumber(userId); if (phoneNum == null) { TrueHomeContext.setPhoneNumber(ap.PhoneNumber, userId); } ap.IDUser = userId; var id = await TrueHomeContext.createApartment(ap); return(JObject.Parse("{\"id\": " + id + ", \"UploadStatus\": " + 1 + "}")); }
public JObject getPhoneNumber() { var userId = User.FindFirst("sub")?.Value; string phoneNumber = TrueHomeContext.getPhoneNumber(userId); string jsonData = null; if (phoneNumber == null) { jsonData = "{ 'phoneNumber': null }"; } else { jsonData = "{'phoneNumber': " + $"'{phoneNumber}'" + "'}"; } return(JObject.Parse(jsonData)); }