private static UserProfile ToProfile(ProfileTableEntity profileTableEntity) { return(new UserProfile { Username = profileTableEntity.RowKey, FirstName = profileTableEntity.FirstName, LastName = profileTableEntity.LastName, ProfilePictureId = profileTableEntity.ProfilePictureId }); }
private static Profile ToProfile(ProfileTableEntity entity) { return(new Profile { Username = entity.RowKey, Firstname = entity.Firstname, Lastname = entity.Lastname, ProfilePictureId = entity.ProfilePictureId }); }
public async Task DeleteProfile(string username) { try { ProfileTableEntity entity = await RetrieveProfileEntity(username); var deleteOperation = TableOperation.Delete(entity); await _profileTable.ExecuteAsync(deleteOperation); } catch (StorageException e) { throw new StorageErrorException("Could not delete from azure table", e); } }
public async Task <Profile> GetProfile(string username) { try { ProfileTableEntity entity = await RetrieveProfileEntity(username); return(ToProfile(entity)); } catch (StorageException e) { if (e.RequestInformation.HttpStatusCode == 404) // not found { throw new ProfileNotFoundException($"Profile {username} not found"); } throw new StorageErrorException("Could not read from Azure Table", e); } }
public async Task AddProfile(Profile profile) { ProfileTableEntity entity = ToEntity(profile); var insertOperation = TableOperation.Insert(entity); try { await _table.ExecuteAsync(insertOperation); } catch (StorageException e) { if (e.RequestInformation.HttpStatusCode == 409) // conflict { throw new ProfileAlreadyExistsException($"Profile {profile.Username} already exists"); } throw new StorageErrorException("Could not write to Azure Table", e); } }