-
Notifications
You must be signed in to change notification settings - Fork 113
Expand file tree
/
Copy pathIRepository.cs
More file actions
206 lines (182 loc) · 9.66 KB
/
IRepository.cs
File metadata and controls
206 lines (182 loc) · 9.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//-----------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// ---------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using PhotoSharingApp.Portable.DataContracts;
namespace PhotoSharingApp.AppService.Shared.Repositories
{
/// <summary>
/// Interface to the data access layer.
/// </summary>
public interface IRepository : IDisposable
{
/// <summary>
/// Creates a new category with the provided name.
/// </summary>
/// <param name="name">The category name to be created.</param>
/// <returns>The created category.</returns>
Task<CategoryContract> CreateCategory(string name);
/// <summary>
/// Inserts a new user record in the database.
/// </summary>
/// <param name="registrationReference">The Azure Mobile Service user id.</param>
/// <returns>Updated user object.</returns>
Task<UserContract> CreateUser(string registrationReference);
/// <summary>
/// Deletes an annotation.
/// </summary>
/// <param name="annotationId">Id of annotation to be deleted.</param>
/// <param name="userRegistrationReference">userRegistrationReference of annotation to be deleted.</param>
Task DeleteAnnotation(string annotationId, string userRegistrationReference);
/// <summary>
/// Deletes all the data for the provided photo id.
/// </summary>
/// <param name="photoId">Id of the photo to be deleted.</param>
/// <param name="userRegistrationReference">Azure Mobile Service user id.</param>
Task DeletePhoto(string photoId, string userRegistrationReference);
/// <summary>
/// Releases resources.
/// </summary>
new void Dispose();
/// <summary>
/// Fetches all the categories and sorts them by name.
/// </summary>
/// <returns>List interface of CategoryContract sorted by name.</returns>
Task<IList<CategoryContract>> GetCategories();
/// <summary>
/// Retrieves all the categories that have atleast one photo and also retrieves
/// number of provided thumbnails for the photos in each category.
/// </summary>
/// <param name="numberOfThumbnails">Max number of thumbnails per category.</param>
/// <returns>List interface of CategoryPreviewContract.</returns>
Task<IList<CategoryPreviewContract>> GetCategoriesPreview(int numberOfThumbnails);
/// <summary>
/// Fetches the photo stream data for a provided category.
/// </summary>
/// <param name="categoryId">THe category id.</param>
/// <param name="continuationToken">Last captured ticks in the form of a string.</param>
/// <returns>List of photos up to the page size.</returns>
Task<PagedResponse<PhotoContract>> GetCategoryPhotoStream(string categoryId, string continuationToken);
/// <summary>
/// Gets hero photos.
/// </summary>
/// <param name="count">The number of hero photos.</param>
/// <param name="daysOld">The number of days old the photos can be.</param>
/// <returns>List interface of hero photos.</returns>
Task<IList<PhotoContract>> GetHeroPhotos(int count, int daysOld);
/// <summary>
/// Gets the leaderboard data.
/// </summary>
/// <param name="mostGoldCategoriesCount">Count of categories.</param>
/// <param name="mostGoldPhotosCount">Count of photos.</param>
/// <param name="mostGoldUsersCount">Count of wealthiest users.</param>
/// <param name="mostGivingUsersCount">Count of most giving users.</param>
/// <returns>The leaderboard data.</returns>
Task<LeaderboardContract> GetLeaderboard(int mostGoldCategoriesCount, int mostGoldPhotosCount,
int mostGoldUsersCount, int mostGivingUsersCount);
/// <summary>
/// Gets the photo data for provided photo id.
/// </summary>
/// <param name="id">The photo id.</param>
/// <returns>The requested photo.</returns>
Task<PhotoContract> GetPhoto(string id);
/// <summary>
/// Gets the list of photos with a specific status.
/// </summary>
/// <param name="status">The photo status.</param>
/// <returns>A list of photos with provided status.</returns>
Task<PagedResponse<PhotoContract>> GetPhotosWithStatus(PhotoStatus status);
/// <summary>
/// Gets the user by an existing app user id OR registrationReference
/// from Azure App Services auth mechanism as the userId may not be known
/// at time of entry.
/// </summary>
/// <param name="userId">The app user id.</param>
/// <param name="registrationReference">[Optional] The Azure App Service user id. Default value is null.</param>
/// <returns>The User contract.</returns>
Task<UserContract> GetUser(string userId, string registrationReference = null);
/// <summary>
/// Fetches the photo stream data for a specified user.
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="continuationToken">Last captured ticks in the form of a string.</param>
/// <param name="includeNonActivePhotos">By default, false. If true, non-active photos are included.</param>
/// <returns>List of photos up to the page size.</returns>
Task<PagedResponse<PhotoContract>> GetUserPhotoStream(string userId, string continuationToken, bool includeNonActivePhotos = false);
/// <summary>
/// Checks if the database exists and initializes it if it doesn't.
/// </summary>
Task InitializeDatabaseIfNotExisting(string serverPath);
/// <summary>
/// Inserts the annotation object and performs the required gold transactions.
/// </summary>
/// <param name="annotation">Annotation to be inserted.</param>
/// <returns>AnnotationContract.</returns>
Task<AnnotationContract> InsertAnnotation(AnnotationContract annotation);
/// <summary>
/// Inserts receipt and adds gold to user.
/// </summary>
/// <param name="validatedIapReciept">Validated receipt values.</param>
/// <returns>User object containing new gold balance.</returns>
Task<UserContract> InsertIapPurchase(IapPurchaseContract validatedIapReciept);
/// <summary>
/// Insert the photo object into storage.
/// </summary>
/// <param name="photo">Photo Object.</param>
/// <param name="goldIncrement">Gold to award for new photo.</param>
/// <returns>New PhotoContract with updated user balance.</returns>
Task<PhotoContract> InsertPhoto(PhotoContract photo, int goldIncrement);
/// <summary>
/// Inserts a report into Report table.
/// </summary>
/// <param name="report">The report being inserted.</param>
/// <param name="userRegistrationReference">Azure Mobile Service user id who is reporting it.</param>
/// <returns>The inserted Report.</returns>
Task<ReportContract> InsertReport(ReportContract report, string userRegistrationReference);
/// <summary>
/// Forces a reinitalization of the database, deleting any existing data.
/// </summary>
Task ReinitializeDatabase(string serverPath);
/// <summary>
/// Updates an existing photo object's category and description fields.
/// </summary>
/// <param name="photoContract">Photo object.</param>
/// <returns>PhotoContract containing updated data.</returns>
Task<PhotoContract> UpdatePhoto(PhotoContract photoContract);
/// <summary>
/// Updates the status of the stored photo.
/// </summary>
/// <param name="photoContract">Photo object.</param>
/// <returns>PhotoContract containing updated data.</returns>
Task<PhotoContract> UpdatePhotoStatus(PhotoContract photoContract);
/// <summary>
/// Updates the user profile picture. User gold balance is also updated if it is the first time
/// the user is updating their profile picture.
/// </summary>
/// <param name="user">We need the whole user object as it is assumed the client will have given the photoId and url.</param>
/// <returns>A new UserContract object.</returns>
Task<UserContract> UpdateUser(UserContract user);
}
}