C# 클래스 PhotoSharingApp.AppService.Shared.Repositories.DocumentDbRepository

The DocumentDB data layer class.
상속: IRepository
파일 보기 프로젝트 열기: Microsoft/Appsample-Photosharing 1 사용 예제들

Private Properties

프로퍼티 타입 설명
CreateDocumentDbCollection Task
CreateDocumentDbDatabase Task
CreateGetRecentPhotosForCategoriesStoredProcedure System.Threading.Tasks.Task
CreatePhotoContractsAndLoadUserData Task>
CreateTransferGoldStoredProcedure System.Threading.Tasks.Task
ExecuteGoldTransactionSproc Task
GetAllCategoryDocuments Task>
GetAllUserDocumentsFromIdList Task>
GetAnnotationDocument PhotoSharingApp.AppService.Shared.Models.DocumentDB.AnnotationDocument
GetCategoryDocument PhotoSharingApp.AppService.Shared.Models.DocumentDB.CategoryDocument
GetHighestGivingUsers Task>>
GetHighestNetWorthCategories Task>>
GetHighestNetWorthPhotos Task>>
GetHighestNetWorthUser Task>>
GetParentPhotoDocument PhotoSharingApp.AppService.Shared.Models.DocumentDB.PhotoDocument
GetPhotoDocument PhotoSharingApp.AppService.Shared.Models.DocumentDB.PhotoDocument
GetUserDocumentByRegistrationReference PhotoSharingApp.AppService.Shared.Models.DocumentDB.UserDocument
GetUserDocumentByUserId PhotoSharingApp.AppService.Shared.Models.DocumentDB.UserDocument
InitializeStoredProceduresIfNotExisting System.Threading.Tasks.Task
ReplacePhotoDocument Task
ReplaceUserDocument Task
UpdateAnnotationDocument System.Threading.Tasks.Task

공개 메소드들

메소드 설명
CheckIfDatabaseAndCollectionExist ( ) : bool

Checks if database and collection exist.

CreateCategory ( string name ) : Task

Creates a new category with the provided name.

CreateUser ( string registrationReference ) : Task

Inserts a new user record in the database.

DeleteAnnotation ( string annotationId, string userRegistrationReference ) : System.Threading.Tasks.Task

Deletes an annotation.

DeletePhoto ( string photoId, string userRegistrationReference ) : System.Threading.Tasks.Task

Deletes all the data for the provided photo id.

Dispose ( ) : void

Initiates the process of releasing resources.

DocumentDbRepository ( EnvironmentDefinitionBase environmentDefinition ) : System

The DocumentDbRepository constructor.

GetCategories ( ) : Task>

Fetches all the categories and sorts them by name.

GetCategoriesPreview ( int numberOfThumbnails ) : Task>

Retrieves all the categories that have atleast one photo and also retrieves number of provided thumbnails for the photos in each category.

GetCategoryPhotoStream ( string categoryId, string continuationToken = null ) : Task>

Fetches the photo stream data for a provided category.

GetHeroPhotos ( int count, int daysOld ) : Task>

Gets hero photos.

GetLeaderboard ( int mostGoldCategoriesCount, int mostGoldPhotosCount, int mostGoldUsersCount, int mostGivingUsersCount ) : Task

Gets the leaderboard data.

GetPhoto ( string id ) : Task

Gets the photo data for provided photo id.

GetPhotosWithStatus ( PhotoStatus status ) : Task>

Gets the list of photos with a specific status.

GetUser ( string userId, string registrationReference = null ) : Task

Gets the user by an existing app user id OR registrationReference from Azure Mobile Services auth mechanism as the userId may not be known at time of entry.

GetUserPhotoStream ( string userId, string continuationToken, bool includeNonActivePhotos = false ) : Task>

Fetches the photo stream data for a specified user.

InitializeDatabaseIfNotExisting ( string serverPath ) : System.Threading.Tasks.Task

Checks if the defined document database and collection exists and initializes them if they don't.

InsertAnnotation ( AnnotationContract annotationContract ) : Task

Inserts the annotation object and performs the required gold transactions.

InsertIapPurchase ( IapPurchaseContract validatedIapReciept ) : Task

Inserts receipt and adds gold to user.

InsertPhoto ( PhotoContract photo, int goldIncrement ) : Task

Insert the photo object into storage.

InsertReport ( ReportContract reportContract, string userRegistrationReference ) : Task

Inserts a report into Report table.

ReinitializeDatabase ( string serverPath ) : System.Threading.Tasks.Task

Forces a reinitalization of the database by recreating the document database and collection.

UpdatePhoto ( PhotoContract photoContract ) : Task

Updates an existing photo object's category and description fields.

UpdatePhotoStatus ( PhotoContract photoContract ) : Task

Updates the status of the stored photo object.

UpdateUser ( UserContract userContract ) : Task

Updates the user profile picture. User gold balance is also updated if it is the first time the user is updating their profile picture.

보호된 메소드들

메소드 설명
Dispose ( bool disposing ) : void

Releases resources.

비공개 메소드들

메소드 설명
CreateDocumentDbCollection ( Microsoft.Azure.Documents.Database database ) : Task
CreateDocumentDbDatabase ( ) : Task
CreateGetRecentPhotosForCategoriesStoredProcedure ( string serverPath ) : System.Threading.Tasks.Task
CreatePhotoContractsAndLoadUserData ( IList photoDocuments ) : Task>

Processes a list of photo json documents and creates PhotoContract for them, as well as fetching and setting the proper UserContract objects for PhotoContract.User and AnnotationContract.From fields.

CreateTransferGoldStoredProcedure ( string serverPath ) : System.Threading.Tasks.Task
ExecuteGoldTransactionSproc ( string toUserId, string fromUserId, int goldValue, GoldTransactionType transactionType, string photoId = null ) : Task
GetAllCategoryDocuments ( ) : Task>
GetAllUserDocumentsFromIdList ( ICollection listOfUserIds ) : Task>
GetAnnotationDocument ( string annotationId ) : AnnotationDocument
GetCategoryDocument ( string categoryId ) : CategoryDocument
GetHighestGivingUsers ( int count ) : Task>>
GetHighestNetWorthCategories ( int count ) : Task>>
GetHighestNetWorthPhotos ( int count ) : Task>>
GetHighestNetWorthUser ( int count ) : Task>>
GetParentPhotoDocument ( string annotationId ) : PhotoDocument
GetPhotoDocument ( string id ) : PhotoDocument
GetUserDocumentByRegistrationReference ( string registrationReference ) : UserDocument
GetUserDocumentByUserId ( string userId ) : UserDocument
InitializeStoredProceduresIfNotExisting ( string serverPath ) : System.Threading.Tasks.Task
ReplacePhotoDocument ( PhotoDocument photoDocument ) : Task
ReplaceUserDocument ( UserDocument userDocument ) : Task
UpdateAnnotationDocument ( AnnotationDocument annotationDocument ) : System.Threading.Tasks.Task

메소드 상세

CheckIfDatabaseAndCollectionExist() 공개 메소드

Checks if database and collection exist.
public CheckIfDatabaseAndCollectionExist ( ) : bool
리턴 bool

CreateCategory() 공개 메소드

Creates a new category with the provided name.
public CreateCategory ( string name ) : Task
name string The category name to be created.
리턴 Task

CreateUser() 공개 메소드

Inserts a new user record in the database.
public CreateUser ( string registrationReference ) : Task
registrationReference string The Azure Mobile Service user id.
리턴 Task

DeleteAnnotation() 공개 메소드

Deletes an annotation.
public DeleteAnnotation ( string annotationId, string userRegistrationReference ) : System.Threading.Tasks.Task
annotationId string Id of annotation to be deleted.
userRegistrationReference string userRegistrationReference of annotation to be deleted.
리턴 System.Threading.Tasks.Task

DeletePhoto() 공개 메소드

Deletes all the data for the provided photo id.
public DeletePhoto ( string photoId, string userRegistrationReference ) : System.Threading.Tasks.Task
photoId string Id of the photo to be deleted.
userRegistrationReference string Azure Mobile Service user id.
리턴 System.Threading.Tasks.Task

Dispose() 공개 메소드

Initiates the process of releasing resources.
public Dispose ( ) : void
리턴 void

Dispose() 보호된 메소드

Releases resources.
protected Dispose ( bool disposing ) : void
disposing bool If we need to release resources or not.
리턴 void

DocumentDbRepository() 공개 메소드

The DocumentDbRepository constructor.
public DocumentDbRepository ( EnvironmentDefinitionBase environmentDefinition ) : System
environmentDefinition PhotoSharingApp.AppService.Shared.Context.EnvironmentDefinitionBase The specified environment definition.
리턴 System

GetCategories() 공개 메소드

Fetches all the categories and sorts them by name.
public GetCategories ( ) : Task>
리턴 Task>

GetCategoriesPreview() 공개 메소드

Retrieves all the categories that have atleast one photo and also retrieves number of provided thumbnails for the photos in each category.
public GetCategoriesPreview ( int numberOfThumbnails ) : Task>
numberOfThumbnails int Max number of thumbnails per category.
리턴 Task>

GetCategoryPhotoStream() 공개 메소드

Fetches the photo stream data for a provided category.
public GetCategoryPhotoStream ( string categoryId, string continuationToken = null ) : Task>
categoryId string The category id.
continuationToken string Continuation token from previous .
리턴 Task>

GetHeroPhotos() 공개 메소드

Gets hero photos.
public GetHeroPhotos ( int count, int daysOld ) : Task>
count int The number of hero photos.
daysOld int The number of days old the photos can be.
리턴 Task>

GetLeaderboard() 공개 메소드

Gets the leaderboard data.
public GetLeaderboard ( int mostGoldCategoriesCount, int mostGoldPhotosCount, int mostGoldUsersCount, int mostGivingUsersCount ) : Task
mostGoldCategoriesCount int Count of categories.
mostGoldPhotosCount int Count of photos.
mostGoldUsersCount int Count of wealthiest users.
mostGivingUsersCount int Count of most giving users.
리턴 Task

GetPhoto() 공개 메소드

Gets the photo data for provided photo id.
public GetPhoto ( string id ) : Task
id string The photo id.
리턴 Task

GetPhotosWithStatus() 공개 메소드

Gets the list of photos with a specific status.
public GetPhotosWithStatus ( PhotoStatus status ) : Task>
status PhotoStatus The photo status.
리턴 Task>

GetUser() 공개 메소드

Gets the user by an existing app user id OR registrationReference from Azure Mobile Services auth mechanism as the userId may not be known at time of entry.
public GetUser ( string userId, string registrationReference = null ) : Task
userId string The app user id.
registrationReference string [Optional] The Azure App Service user id. Default value is null.
리턴 Task

GetUserPhotoStream() 공개 메소드

Fetches the photo stream data for a specified user.
public GetUserPhotoStream ( string userId, string continuationToken, bool includeNonActivePhotos = false ) : Task>
userId string The user id.
continuationToken string Last captured ticks in the form of a string.
includeNonActivePhotos bool By default, false. If true, non-active photos are included.
리턴 Task>

InitializeDatabaseIfNotExisting() 공개 메소드

Checks if the defined document database and collection exists and initializes them if they don't.
public InitializeDatabaseIfNotExisting ( string serverPath ) : System.Threading.Tasks.Task
serverPath string
리턴 System.Threading.Tasks.Task

InsertAnnotation() 공개 메소드

Inserts the annotation object and performs the required gold transactions.
public InsertAnnotation ( AnnotationContract annotationContract ) : Task
annotationContract PhotoSharingApp.Portable.DataContracts.AnnotationContract Annotation to be inserted.
리턴 Task

InsertIapPurchase() 공개 메소드

Inserts receipt and adds gold to user.
public InsertIapPurchase ( IapPurchaseContract validatedIapReciept ) : Task
validatedIapReciept PhotoSharingApp.Portable.DataContracts.IapPurchaseContract Validated receipt values.
리턴 Task

InsertPhoto() 공개 메소드

Insert the photo object into storage.
public InsertPhoto ( PhotoContract photo, int goldIncrement ) : Task
photo PhotoSharingApp.Portable.DataContracts.PhotoContract Photo Object.
goldIncrement int Gold to award for new photo.
리턴 Task

InsertReport() 공개 메소드

Inserts a report into Report table.
public InsertReport ( ReportContract reportContract, string userRegistrationReference ) : Task
reportContract PhotoSharingApp.Portable.DataContracts.ReportContract The report being inserted.
userRegistrationReference string Azure Mobile Service user id who is reporting it.
리턴 Task

ReinitializeDatabase() 공개 메소드

Forces a reinitalization of the database by recreating the document database and collection.
public ReinitializeDatabase ( string serverPath ) : System.Threading.Tasks.Task
serverPath string
리턴 System.Threading.Tasks.Task

UpdatePhoto() 공개 메소드

Updates an existing photo object's category and description fields.
public UpdatePhoto ( PhotoContract photoContract ) : Task
photoContract PhotoSharingApp.Portable.DataContracts.PhotoContract Photo object.
리턴 Task

UpdatePhotoStatus() 공개 메소드

Updates the status of the stored photo object.
public UpdatePhotoStatus ( PhotoContract photoContract ) : Task
photoContract PhotoSharingApp.Portable.DataContracts.PhotoContract Photo object.
리턴 Task

UpdateUser() 공개 메소드

Updates the user profile picture. User gold balance is also updated if it is the first time the user is updating their profile picture.
public UpdateUser ( UserContract userContract ) : Task
userContract PhotoSharingApp.Portable.DataContracts.UserContract /// We need the whole user object as it is assumed the client will have given the photoId and /// url. ///
리턴 Task