├── .gitignore ├── Mog.Api.Core ├── Abstractions │ ├── ICacheBase.cs │ ├── IFactory.cs │ ├── IFactoryBase.cs │ ├── IStore.cs │ └── IStoreBase.cs ├── Extensions │ ├── ApplicationExtensions.cs │ ├── MiddlewareExtensions.cs │ ├── ServicesExtensions.cs │ └── WebHostExtensions.cs ├── Logging │ ├── ApplicationSettings.cs │ └── DebugSettings.cs ├── Models │ ├── Blog.cs │ ├── Character.cs │ ├── DatingProfile.cs │ ├── Feed.cs │ ├── Game.cs │ ├── Monster.cs │ ├── Picture.cs │ ├── Stat.cs │ └── User.cs ├── Mog.Api.Core.csproj ├── Security │ └── AppSettings.cs ├── Swagger │ ├── ConfigureSwaggerGenOptions.cs │ ├── ConfigureSwaggerOptions.cs │ ├── ConfigureSwaggerUiOptions.cs │ ├── RemoveVersionFromParameter.cs │ ├── ReplaceVersionWithExactValueInPath.cs │ └── SwaggerSettings.cs └── WebApi │ └── ApiControllerBase.cs ├── Mog.Api.Infrastructure ├── AsheDbContext.cs ├── Data │ ├── BlogFactory.cs │ ├── BlogReactionStore.cs │ ├── BlogStore.cs │ ├── CharacterFactory.cs │ ├── CharacterStore.cs │ ├── DatingProfileFactory.cs │ ├── FeedFactory.cs │ ├── FeedStore.cs │ ├── GameFactory.cs │ ├── MonsterFactory.cs │ ├── PictureStore.cs │ ├── StatFactory.cs │ └── StatStore.cs ├── Migrations │ ├── 20200709124158_Initial.Designer.cs │ ├── 20200709124158_Initial.cs │ ├── 20200818221511_NewPropsToStats.Designer.cs │ ├── 20200818221511_NewPropsToStats.cs │ ├── 20200922211456_NewFeedModel.Designer.cs │ ├── 20200922211456_NewFeedModel.cs │ ├── 20201002115407_UpdateFeedModel.Designer.cs │ ├── 20201002115407_UpdateFeedModel.cs │ ├── 20201003001943_UpdateFeedModelAgain.Designer.cs │ ├── 20201003001943_UpdateFeedModelAgain.cs │ ├── 20201003173204_UpdateFeedReactions.Designer.cs │ ├── 20201003173204_UpdateFeedReactions.cs │ ├── ApplicationDbContextModelSnapshot.cs │ └── AsheDb │ │ ├── 20210923040803_AddedBlogs.Designer.cs │ │ ├── 20210923040803_AddedBlogs.cs │ │ ├── 20210923164659_AddedTitlePropToBlog.Designer.cs │ │ ├── 20210923164659_AddedTitlePropToBlog.cs │ │ ├── 20210924124022_AddedUpdatedPropToBlog.Designer.cs │ │ ├── 20210924124022_AddedUpdatedPropToBlog.cs │ │ └── AsheDbContextModelSnapshot.cs ├── Mog.Api.Infrastructure.csproj └── SerahDbContext.cs ├── Mog.Api ├── Controllers │ ├── API │ │ └── V1 │ │ │ ├── BlogController.cs │ │ │ ├── CharacterController.cs │ │ │ ├── DatingProfileController.cs │ │ │ ├── FeedController.cs │ │ │ ├── GameController.cs │ │ │ ├── MonsterController.cs │ │ │ ├── PictureController.cs │ │ │ └── StatController.cs │ ├── HomeController.cs │ └── SwaggerController.cs ├── Mog.Api.csproj ├── Program.cs ├── Startup.cs ├── Views │ ├── Home │ │ └── Index.cshtml │ ├── Shared │ │ ├── _Layout.cshtml │ │ └── _ValidationScriptsPartial.cshtml │ ├── _ViewImports.cshtml │ └── _ViewStart.cshtml └── wwwroot │ ├── css │ ├── moogleapi-main.min.css │ └── site.css │ ├── customfonts │ ├── JosefinSans-Italic-VariableFont_wght.ttf │ ├── JosefinSans-VariableFont_wght.ttf │ ├── Raleway-Italic-VariableFont_wght.ttf │ └── Raleway-VariableFont_wght.ttf │ ├── favicon.ico │ ├── icons │ ├── apple-touch-icon.png │ ├── moogleapi-icon-192.png │ ├── moogleapi-icon-512.png │ ├── penelo.png │ └── selphie.png │ ├── images │ ├── moogle.png │ └── no-image.png │ ├── js │ ├── moogleapi-main.js │ └── moogleapi-prep.min.js │ ├── lib │ ├── bootstrap │ │ ├── .bower.json │ │ ├── LICENSE │ │ └── dist │ │ │ ├── css │ │ │ ├── bootstrap-grid.css │ │ │ ├── bootstrap-grid.css.map │ │ │ ├── bootstrap-grid.min.css │ │ │ ├── bootstrap-grid.min.css.map │ │ │ ├── bootstrap-reboot.css │ │ │ ├── bootstrap-reboot.css.map │ │ │ ├── bootstrap-reboot.min.css │ │ │ ├── bootstrap-reboot.min.css.map │ │ │ ├── bootstrap.css │ │ │ ├── bootstrap.css.map │ │ │ ├── bootstrap.min.css │ │ │ └── bootstrap.min.css.map │ │ │ ├── fonts │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ └── js │ │ │ ├── bootstrap.bundle.js │ │ │ ├── bootstrap.bundle.js.map │ │ │ ├── bootstrap.bundle.min.js │ │ │ ├── bootstrap.bundle.min.js.map │ │ │ ├── bootstrap.js │ │ │ ├── bootstrap.js.map │ │ │ ├── bootstrap.min.js │ │ │ └── bootstrap.min.js.map │ ├── jquery-validation-unobtrusive │ │ ├── .bower.json │ │ ├── jquery.validate.unobtrusive.js │ │ └── jquery.validate.unobtrusive.min.js │ ├── jquery-validation │ │ ├── .bower.json │ │ ├── LICENSE.md │ │ └── dist │ │ │ ├── additional-methods.js │ │ │ ├── additional-methods.min.js │ │ │ ├── jquery.validate.js │ │ │ └── jquery.validate.min.js │ └── jquery │ │ ├── .bower.json │ │ ├── LICENSE.txt │ │ └── dist │ │ ├── jquery.js │ │ ├── jquery.min.js │ │ └── jquery.min.map │ ├── manifest.json │ └── splashscreens │ ├── ipad_splash.png │ ├── ipadpro1_splash.png │ ├── ipadpro2_splash.png │ ├── ipadpro3_splash.png │ ├── iphone5_splash.png │ ├── iphone6_splash.png │ ├── iphoneplus_splash.png │ ├── iphonex_splash.png │ ├── iphonexr_splash.png │ └── iphonexsmax_splash.png ├── Mog.sln └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | images/* 7 | !images/.gitkeep 8 | 9 | .DS_Store 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.userosscache 15 | *.sln.docstates 16 | 17 | # User-specific files (MonoDevelop/Xamarin Studio) 18 | *.userprefs 19 | 20 | # Build results 21 | [Dd]ebug/ 22 | [Dd]ebugPublic/ 23 | [Rr]elease/ 24 | [Rr]eleases/ 25 | x64/ 26 | x86/ 27 | bld/ 28 | [Bb]in/ 29 | [Oo]bj/ 30 | [Ll]og/ 31 | 32 | # Visual Studio 2015/2017 cache/options directory and VSCode stuff 33 | .vs/ 34 | .vscode/ 35 | # Uncomment if you have tasks that create the project's static files in wwwroot 36 | #wwwroot/ 37 | 38 | # Visual Studio 2017 auto generated files 39 | Generated\ Files/ 40 | 41 | # MSTest test Results 42 | [Tt]est[Rr]esult*/ 43 | [Bb]uild[Ll]og.* 44 | 45 | # NUNIT 46 | *.VisualState.xml 47 | TestResult.xml 48 | 49 | # Build Results of an ATL Project 50 | [Dd]ebugPS/ 51 | [Rr]eleasePS/ 52 | dlldata.c 53 | 54 | # Benchmark Results 55 | BenchmarkDotNet.Artifacts/ 56 | 57 | # .NET Core 58 | project.lock.json 59 | project.fragment.lock.json 60 | appsettings.json 61 | appsettings.Development.json 62 | bundleconfig.json 63 | .DS_Store 64 | artifacts/ 65 | **/Properties/launchSettings.json 66 | 67 | # StyleCop 68 | StyleCopReport.xml 69 | 70 | # Files built by Visual Studio 71 | *_i.c 72 | *_p.c 73 | *_i.h 74 | *.ilk 75 | *.meta 76 | *.obj 77 | *.iobj 78 | *.pch 79 | *.pdb 80 | *.ipdb 81 | *.pgc 82 | *.pgd 83 | *.rsp 84 | *.sbr 85 | *.tlb 86 | *.tli 87 | *.tlh 88 | *.tmp 89 | *.tmp_proj 90 | *.log 91 | *.vspscc 92 | *.vssscc 93 | .builds 94 | *.pidb 95 | *.svclog 96 | *.scc 97 | 98 | # Chutzpah Test files 99 | _Chutzpah* 100 | 101 | # Visual C++ cache files 102 | ipch/ 103 | *.aps 104 | *.ncb 105 | *.opendb 106 | *.opensdf 107 | *.sdf 108 | *.cachefile 109 | *.VC.db 110 | *.VC.VC.opendb 111 | 112 | # Visual Studio profiler 113 | *.psess 114 | *.vsp 115 | *.vspx 116 | *.sap 117 | 118 | # Visual Studio Trace Files 119 | *.e2e 120 | 121 | # TFS 2012 Local Workspace 122 | $tf/ 123 | 124 | # Guidance Automation Toolkit 125 | *.gpState 126 | 127 | # ReSharper is a .NET coding add-in 128 | _ReSharper*/ 129 | *.[Rr]e[Ss]harper 130 | *.DotSettings.user 131 | 132 | # JustCode is a .NET coding add-in 133 | .JustCode 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Visual Studio code coverage results 146 | *.coverage 147 | *.coveragexml 148 | 149 | # NCrunch 150 | _NCrunch_* 151 | .*crunch*.local.xml 152 | nCrunchTemp_* 153 | 154 | # MightyMoose 155 | *.mm.* 156 | AutoTest.Net/ 157 | 158 | # Web workbench (sass) 159 | .sass-cache/ 160 | 161 | # Installshield output folder 162 | [Ee]xpress/ 163 | 164 | # DocProject is a documentation generator add-in 165 | DocProject/buildhelp/ 166 | DocProject/Help/*.HxT 167 | DocProject/Help/*.HxC 168 | DocProject/Help/*.hhc 169 | DocProject/Help/*.hhk 170 | DocProject/Help/*.hhp 171 | DocProject/Help/Html2 172 | DocProject/Help/html 173 | 174 | # Click-Once directory 175 | publish/ 176 | 177 | # Publish Web Output 178 | *.[Pp]ublish.xml 179 | *.azurePubxml 180 | # Note: Comment the next line if you want to checkin your web deploy settings, 181 | # but database connection strings (with potential passwords) will be unencrypted 182 | *.pubxml 183 | *.publishproj 184 | 185 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 186 | # checkin your Azure Web App publish settings, but sensitive information contained 187 | # in these scripts will be unencrypted 188 | PublishScripts/ 189 | 190 | # NuGet Packages 191 | *.nupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | 217 | # Visual Studio cache files 218 | # files ending in .cache can be ignored 219 | *.[Cc]ache 220 | # but keep track of directories ending in .cache 221 | !*.[Cc]ache/ 222 | 223 | # Others 224 | ClientBin/ 225 | ~$* 226 | *~ 227 | *.dbmdl 228 | *.dbproj.schemaview 229 | *.jfm 230 | *.pfx 231 | *.publishsettings 232 | orleans.codegen.cs 233 | 234 | # Including strong name files can present a security risk 235 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 236 | #*.snk 237 | 238 | # Since there are multiple workflows, uncomment next line to ignore bower_components 239 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 240 | #bower_components/ 241 | 242 | # RIA/Silverlight projects 243 | Generated_Code/ 244 | 245 | # Backup & report files from converting an old project file 246 | # to a newer Visual Studio version. Backup files are not needed, 247 | # because we have git ;-) 248 | _UpgradeReport_Files/ 249 | Backup*/ 250 | UpgradeLog*.XML 251 | UpgradeLog*.htm 252 | ServiceFabricBackup/ 253 | *.rptproj.bak 254 | 255 | # SQL Server files 256 | *.mdf 257 | *.ldf 258 | *.ndf 259 | 260 | # Business Intelligence projects 261 | *.rdl.data 262 | *.bim.layout 263 | *.bim_*.settings 264 | *.rptproj.rsuser 265 | 266 | # Microsoft Fakes 267 | FakesAssemblies/ 268 | 269 | # GhostDoc plugin setting file 270 | *.GhostDoc.xml 271 | 272 | # Node.js Tools for Visual Studio 273 | .ntvs_analysis.dat 274 | node_modules/ 275 | package.json 276 | package-lock.json 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # JetBrains Rider 303 | .idea/ 304 | *.sln.iml 305 | 306 | # CodeRush 307 | .cr/ 308 | 309 | # Python Tools for Visual Studio (PTVS) 310 | __pycache__/ 311 | *.pyc 312 | 313 | # Cake - Uncomment if you are using it 314 | # tools/** 315 | # !tools/packages.config 316 | 317 | # Tabs Studio 318 | *.tss 319 | 320 | # Telerik's JustMock configuration file 321 | *.jmconfig 322 | 323 | # BizTalk build output 324 | *.btp.cs 325 | *.btm.cs 326 | *.odx.cs 327 | *.xsd.cs 328 | 329 | # OpenCover UI analysis results 330 | OpenCover/ 331 | 332 | # Azure Stream Analytics local run output 333 | ASALocalRun/ 334 | 335 | # MSBuild Binary and Structured Log 336 | *.binlog 337 | 338 | # NVidia Nsight GPU debugger configuration file 339 | *.nvuser 340 | 341 | # MFractors (Xamarin productivity tool) working folder 342 | .mfractor/ 343 | -------------------------------------------------------------------------------- /Mog.Api.Core/Abstractions/ICacheBase.cs: -------------------------------------------------------------------------------- 1 | namespace Mog.Api.Core.Abstractions 2 | { 3 | public interface ICacheBase 4 | { } 5 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Abstractions/IFactory.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Mog.Api.Core.Abstractions 5 | { 6 | 7 | public interface IFactory : IFactoryBase 8 | { 9 | Task GetAsync(TKey key, CancellationToken cancellationToken = new CancellationToken()); 10 | Task GetByKeyAsync(TKey key, CancellationToken cancellationToken = new CancellationToken()); 11 | } 12 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Abstractions/IFactoryBase.cs: -------------------------------------------------------------------------------- 1 | namespace Mog.Api.Core.Abstractions 2 | { 3 | public interface IFactoryBase 4 | { } 5 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Abstractions/IStore.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | 4 | namespace Mog.Api.Core.Abstractions 5 | { 6 | public interface IStore : IStoreBase 7 | { 8 | Task AddAsync(T entity, CancellationToken cancellationToken = new CancellationToken()); 9 | 10 | Task UpdateAsync(T entity, CancellationToken cancellationToken = new CancellationToken()); 11 | Task DeleteAsync(T entity, CancellationToken cancellationToken = new CancellationToken()); 12 | } 13 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Abstractions/IStoreBase.cs: -------------------------------------------------------------------------------- 1 | namespace Mog.Api.Core.Abstractions 2 | { 3 | public interface IStoreBase 4 | { } 5 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Extensions/ApplicationExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using System.Net.Http; 3 | using Azure.Storage; 4 | using Azure.Storage.Blobs; 5 | using Microsoft.WindowsAzure.Storage; 6 | using Microsoft.WindowsAzure.Storage.Auth; 7 | using Microsoft.WindowsAzure.Storage.Blob; 8 | using Newtonsoft.Json; 9 | 10 | namespace Mog.Api.Core.Extensions 11 | { 12 | public class ApplicationExtensions 13 | { 14 | public static CloudBlobContainer ConfigureBlobContainer(string account, string key) 15 | { 16 | // Configures container based on credentials passed in. 17 | var storageCredentials = new StorageCredentials(account, key); 18 | var cloudStorageAccount = new CloudStorageAccount(storageCredentials, true); 19 | var cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); 20 | var container = cloudBlobClient.GetContainerReference("images"); 21 | return container; 22 | } 23 | 24 | public static async Task Get(string user) 25 | { 26 | using (var client = new HttpClient()) 27 | { 28 | var result = await client.GetAsync("https://chocobo.moogleapi.com/v1/manage/get/" + user); 29 | result.EnsureSuccessStatusCode(); 30 | string resultString = await result.Content.ReadAsStringAsync(); 31 | T resultContent = JsonConvert.DeserializeObject(resultString); 32 | return resultContent; 33 | } 34 | } 35 | 36 | public static string ModifyOriginForSearch(string origin) 37 | { 38 | switch (origin) 39 | { 40 | case "1": 41 | case "01": 42 | case "i": 43 | case "I": 44 | case "one": 45 | case "final fantasy i": 46 | case "final fantasy 1": 47 | case "final fantasy one": 48 | origin = "Final Fantasy I"; 49 | break; 50 | case "2": 51 | case "02": 52 | case "two": 53 | case "ii": 54 | case "II": 55 | case "final fantasy ii": 56 | case "final fantasy 2": 57 | case "final fantasy two": 58 | origin = "Final Fantasy II"; 59 | break; 60 | case "3": 61 | case "03": 62 | case "three": 63 | case "iii": 64 | case "III": 65 | case "final fantasy iii": 66 | case "final fantasy 3": 67 | case "final fantasy three": 68 | origin = "Final Fantasy III"; 69 | break; 70 | case "4": 71 | case "04": 72 | case "four": 73 | case "iv": 74 | case "IV": 75 | case "final fantasy iv": 76 | case "final fantasy 4": 77 | case "final fantasy four": 78 | origin = "Final Fantasy IV"; 79 | break; 80 | case "5": 81 | case "05": 82 | case "five": 83 | case "v": 84 | case "V": 85 | case "final fantasy v": 86 | case "final fantasy 5": 87 | case "final fantasy five": 88 | origin = "Final Fantasy V"; 89 | break; 90 | case "6": 91 | case "06": 92 | case "six": 93 | case "vi": 94 | case "VI": 95 | case "final fantasy vi": 96 | case "final fantasy 6": 97 | case "final fantasy six": 98 | origin = "Final Fantasy VI"; 99 | break; 100 | case "7": 101 | case "07": 102 | case "seven": 103 | case "vii": 104 | case "VII": 105 | case "final fantasy vii": 106 | case "final fantasy 7": 107 | case "final fantasy seven": 108 | origin = "Final Fantasy VII"; 109 | break; 110 | case "8": 111 | case "08": 112 | case "eight": 113 | case "viii": 114 | case "VIII": 115 | case "final fantasy viii": 116 | case "final fantasy 8": 117 | case "final fantasy eight": 118 | origin = "Final Fantasy VIII"; 119 | break; 120 | case "9": 121 | case "09": 122 | case "nine": 123 | case "ix": 124 | case "IX": 125 | case "final fantasy ix": 126 | case "final fantasy 9": 127 | case "final fantasy nine": 128 | origin = "Final Fantasy IX"; 129 | break; 130 | case "10": 131 | case "ten": 132 | case "x": 133 | case "X": 134 | case "final fantasy x": 135 | case "final fantasy 10": 136 | case "final fantasy ten": 137 | origin = "Final Fantasy X"; 138 | break; 139 | case "10-2": 140 | case "10 2": 141 | case "ten-2": 142 | case "ten 2": 143 | case "x-2": 144 | case "x2": 145 | case "X-2": 146 | case "X2": 147 | case "final fantasy x2": 148 | case "final fantasy 10-2": 149 | case "final fantasy ten 2": 150 | origin = "Final Fantasy X-2"; 151 | break; 152 | case "12": 153 | case "twelve": 154 | case "xii": 155 | case "XII": 156 | case "final fantasy xii": 157 | case "final fantasy 12": 158 | case "final fantasy twelve": 159 | origin = "Final Fantasy XII"; 160 | break; 161 | case "13": 162 | case "thirteen": 163 | case "xiii": 164 | case "XIII": 165 | case "final fantasy xiii": 166 | case "final fantasy 13": 167 | case "final fantasy thirteen": 168 | origin = "Final Fantasy XIII"; 169 | break; 170 | case "13-2": 171 | case "13 2": 172 | case "thirteen-2": 173 | case "thirteen 2": 174 | case "xiii-2": 175 | case "xiii2": 176 | case "XIII-2": 177 | case "XIII2": 178 | case "final fantasy xiii2": 179 | case "final fantasy 13-2": 180 | case "final fantasy thirteen 2": 181 | origin = "Final Fantasy X-2"; 182 | break; 183 | case "14": 184 | case "fourteen": 185 | case "xiv": 186 | case "XIV": 187 | case "final fantasy xiv": 188 | case "final fantasy 14": 189 | case "final fantasy fourteen": 190 | origin = "Final Fantasy XIV"; 191 | break; 192 | } 193 | return origin; 194 | } 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /Mog.Api.Core/Extensions/MiddlewareExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | 3 | namespace Mog.Api.Core.Extensions 4 | { 5 | public static class MiddlewareExtensions 6 | { 7 | public static void UseSwaggerDocuments(this IApplicationBuilder app) 8 | { 9 | app.UseSwagger(); 10 | app.UseSwaggerUI(); 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Extensions/ServicesExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IdentityModel.Tokens.Jwt; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Collections.Generic; 7 | using Microsoft.AspNetCore.Authentication.JwtBearer; 8 | using Microsoft.EntityFrameworkCore; 9 | using Microsoft.Extensions.Configuration; 10 | using Microsoft.Extensions.DependencyInjection; 11 | using Microsoft.Extensions.Options; 12 | using Microsoft.IdentityModel.Tokens; 13 | using Swashbuckle.AspNetCore.Swagger; 14 | using Swashbuckle.AspNetCore.SwaggerGen; 15 | using Swashbuckle.AspNetCore.SwaggerUI; 16 | using Mog.Api.Core.Abstractions; 17 | using Mog.Api.Core.Security; 18 | using Mog.Api.Core.Swagger; 19 | 20 | namespace Mog.Api.Core.Extensions 21 | { 22 | public static class ServicesExtensions 23 | { 24 | public static IServiceCollection AddApiVersionWithExplorer(this IServiceCollection services) 25 | { 26 | return services 27 | .AddVersionedApiExplorer(options => 28 | { 29 | options.GroupNameFormat = "'v'VVV"; 30 | options.SubstituteApiVersionInUrl = true; 31 | }) 32 | .AddApiVersioning(options => 33 | { 34 | options.AssumeDefaultVersionWhenUnspecified = false; 35 | options.ReportApiVersions = true; 36 | }); 37 | } 38 | 39 | public static IServiceCollection AddEntityFramework(this IServiceCollection services, IConfiguration configuration) 40 | where T:DbContext, IT where IT : class 41 | { 42 | var migrationAssembly = typeof(T).Assembly.GetName().Name; 43 | 44 | return services.AddEntityFrameworkSqlServer() 45 | .AddDbContext((serviceProvider, options) => 46 | options.UseSqlServer( 47 | configuration.GetConnectionString("DefaultConnection"), 48 | x => x.MigrationsAssembly(migrationAssembly) 49 | ).UseInternalServiceProvider(serviceProvider)) 50 | .AddScoped(); 51 | } 52 | 53 | public static IServiceCollection AddSwaggerOptions(this IServiceCollection services) 54 | { 55 | return services 56 | .AddTransient, ConfigureSwaggerOptions>() 57 | .AddTransient, ConfigureSwaggerUiOptions>() 58 | .AddTransient, ConfigureSwaggerGenOptions>(); 59 | } 60 | 61 | public static IServiceCollection AddJwtAuthentication(this IServiceCollection services, IConfigurationSection configSection) 62 | { 63 | var appSettings = configSection.Get(); 64 | var key = Encoding.UTF8.GetBytes(appSettings.Secret); 65 | services.AddAuthentication(x => 66 | { 67 | x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; 68 | x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; 69 | x.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; 70 | }) 71 | .AddJwtBearer(x => 72 | { 73 | x.RequireHttpsMetadata = false; 74 | x.SaveToken = true; 75 | x.TokenValidationParameters = new TokenValidationParameters 76 | { 77 | ValidateIssuerSigningKey = true, 78 | IssuerSigningKey = new SymmetricSecurityKey(key), 79 | ValidateIssuer = true, 80 | ValidIssuer = "chocoboAPI", 81 | ValidateAudience = true, 82 | ValidateLifetime = true, 83 | ValidAudiences = new List() { "moogleAPI" } 84 | }; 85 | }); 86 | JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); 87 | 88 | return services; 89 | } 90 | 91 | public static IServiceCollection AddFactories(this IServiceCollection services, Assembly assembly) 92 | { 93 | var interfaceType = typeof(IFactoryBase); 94 | 95 | return ServiceCollection(services, assembly, interfaceType); 96 | } 97 | 98 | public static IServiceCollection AddStores(this IServiceCollection services, Assembly assembly) 99 | { 100 | var interfaceType = typeof(IStoreBase); 101 | 102 | return ServiceCollection(services, assembly, interfaceType); 103 | } 104 | 105 | public static IServiceCollection AddCache(this IServiceCollection services, Assembly assembly) 106 | { 107 | var interfaceType = typeof(ICacheBase); 108 | 109 | return ServiceCollection(services, assembly, interfaceType); 110 | } 111 | 112 | private static IServiceCollection ServiceCollection(IServiceCollection services, Assembly assembly, Type interfaceType) 113 | { 114 | var typesToRegister = assembly 115 | .GetTypes() 116 | .Where(x => 117 | !string.IsNullOrEmpty(x.Namespace) 118 | && x.IsClass 119 | && interfaceType.IsAssignableFrom(x)) 120 | .ToList(); 121 | 122 | foreach (var type in typesToRegister) 123 | { 124 | var repositoryInterfaces = type.GetInterfaces() 125 | .Where(interfaceType.IsAssignableFrom); 126 | 127 | foreach (var repositoryInterface in repositoryInterfaces) 128 | { 129 | services.AddTransient(repositoryInterface, type); 130 | } 131 | } 132 | 133 | return services; 134 | } 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /Mog.Api.Core/Extensions/WebHostExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Newtonsoft.Json; 7 | using Mog.Api.Core.Logging; 8 | 9 | namespace Mog.Api.Core.Extensions 10 | { 11 | public static class WebHostExtensions 12 | { 13 | public static IWebHost RegisterDefaultJson(this IWebHost webHost) 14 | { 15 | var settings = webHost.Services.GetService(); 16 | JsonConvert.DefaultSettings = () => settings; 17 | return webHost; 18 | } 19 | 20 | public static IWebHost MigrateDatabase(this IWebHost webHost) where T: DbContext 21 | { 22 | var environment = webHost.Services.GetService(); 23 | if (!environment.IsDevelopment()) 24 | return webHost; 25 | 26 | try 27 | { 28 | var serviceScopeFactory = webHost.Services.GetRequiredService(); 29 | using (var scope = serviceScopeFactory.CreateScope()) 30 | using (var context = scope.ServiceProvider.GetRequiredService()) 31 | { 32 | if (context.Database.GetPendingMigrations().Any()) 33 | { 34 | context.Database.Migrate(); 35 | } 36 | } 37 | } 38 | catch 39 | { 40 | if (DebugSettings.IsDebugging) 41 | { 42 | throw; 43 | } 44 | } 45 | 46 | return webHost; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Logging/ApplicationSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Mog.Api.Core.Logging 2 | { 3 | public class ApplicationMetadata 4 | { 5 | public string ApplicationName { get; set; } 6 | } 7 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Logging/DebugSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Mog.Api.Core.Logging 2 | { 3 | public class DebugSettings 4 | { 5 | public static bool IsDebugging => 6 | #if DEBUG 7 | true; 8 | #else 9 | false; 10 | #endif 11 | } 12 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Models/Blog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using Newtonsoft.Json; 5 | 6 | namespace Mog.Api.Core.Models 7 | { 8 | public class Blog 9 | { 10 | public Guid Id { get; set; } 11 | [Required] 12 | [MaxLength(50)] 13 | public string Title { get; set; } 14 | [Required] 15 | public string Content { get; set; } 16 | public int Like { get; set; } 17 | public int Dislike { get; set; } 18 | public int Love { get; set; } 19 | public DateTimeOffset Created { get; set;} 20 | public DateTimeOffset Updated { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Models/Character.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using Newtonsoft.Json; 5 | 6 | namespace Mog.Api.Core.Models 7 | { 8 | public class Character 9 | { 10 | public Guid Id { get; set; } 11 | [Required] 12 | public string Name { get; set; } 13 | public string JapaneseName { get; set; } 14 | [Required] 15 | public string Age { get; set; } 16 | [Required] 17 | public string Gender { get; set; } 18 | [Required] 19 | public string Race { get; set; } 20 | [Required] 21 | public string Job { get; set; } 22 | public string Height { get; set; } 23 | public string Weight { get; set; } 24 | [Required] 25 | public string Origin { get; set; } 26 | public string Description { get; set; } 27 | public ICollection Pictures { get; set; } 28 | public ICollection Stats { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Models/DatingProfile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel.DataAnnotations.Schema; 5 | using Newtonsoft.Json; 6 | 7 | namespace Mog.Api.Core.Models 8 | { 9 | public class DatingProfile 10 | { 11 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 12 | [Key] 13 | [JsonIgnore] 14 | public Guid Id { get; set; } 15 | public string Bio { get; set; } 16 | public string Age { get; set; } 17 | public string Gender { get; set; } 18 | public ICollection Responses { get; set; } 19 | [JsonIgnore] 20 | public Guid CharacterId { get; set; } 21 | [ForeignKey("CharacterId")] 22 | public Character Character { get; set; } 23 | } 24 | 25 | public class DatingResponse 26 | { 27 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 28 | [Key] 29 | [JsonIgnore] 30 | public Guid Id { get; set ;} 31 | public string Response { get; set; } 32 | [JsonIgnore] 33 | public Guid DatingProfileId { get; set; } 34 | [ForeignKey("DatingProfileId")] 35 | public DatingProfile DatingProfile { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Models/Feed.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Mog.Api.Core.Models 4 | { 5 | public class Feed 6 | { 7 | public Guid Id { get; set; } 8 | public Guid CharacterId { get; set; } 9 | public string CharacterName { get; set; } 10 | public int Update { get; set; } 11 | public int Addition { get; set; } 12 | public int Deletion { get; set; } 13 | public int StatUpdate { get; set; } 14 | public int StatAddition { get; set; } 15 | public int StatDeletion { get; set; } 16 | public int PhotoUpdate { get; set; } 17 | public int Like { get; set; } 18 | public int Dislike { get; set; } 19 | public int Love { get; set; } 20 | public string UserName { get; set; } 21 | public string UserFirstName { get; set; } 22 | public string UserPhoto { get; set; } 23 | public DateTime TimeStamp { get; set; } 24 | } 25 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Models/Game.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.ComponentModel.DataAnnotations; 4 | using System.ComponentModel; 5 | 6 | namespace Mog.Api.Core.Models 7 | { 8 | public class Game 9 | { 10 | public Guid GameId { get; set; } 11 | [Required] 12 | public string Title { get; set; } 13 | public string Picture { get; set; } 14 | public string Platform { get; set; } 15 | [DisplayName("Release Date")] 16 | public string ReleaseDate { get; set; } 17 | public string Description { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Mog.Api.Core/Models/Monster.cs: -------------------------------------------------------------------------------- 1 | 2 | using System; 3 | using System.ComponentModel.DataAnnotations; 4 | using Newtonsoft.Json; 5 | 6 | namespace Mog.Api.Core.Models 7 | { 8 | public class Monster 9 | { 10 | public Guid MonsterId { get; set; } 11 | [Required] 12 | public string Name { get; set; } 13 | public string JapaneseName { get; set; } 14 | public string ElementalAffinity { get; set; } 15 | public string ElementalWeakness { get; set; } 16 | public int HitPoints{ get; set; } 17 | public int ManaPoints { get; set; } 18 | public int Attack { get; set; } 19 | public int Defense { get; set; } 20 | public string Picture { get; set; } 21 | public string Description { get; set; } 22 | public string Game { get; set; } 23 | [JsonIgnore] 24 | public string AddedBy { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Mog.Api.Core/Models/Picture.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | 5 | namespace Mog.Api.Core.Models 6 | { 7 | public class Picture 8 | { 9 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 10 | [Key] 11 | public Guid Id { get; set; } 12 | public string Url { get; set; } 13 | public int Primary { get; set; } 14 | public Guid CollectionId { get; set; } 15 | [ForeignKey("CollectionId")] 16 | public Character Character { get; set; } 17 | } 18 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Models/Stat.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.DataAnnotations; 3 | using System.ComponentModel.DataAnnotations.Schema; 4 | using Newtonsoft.Json; 5 | 6 | namespace Mog.Api.Core.Models 7 | { 8 | 9 | public class Stat 10 | { 11 | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] 12 | [Key] 13 | public Guid Id { get; set; } 14 | public string Platform { get; set; } 15 | public int Level { get; set; } 16 | public string Class { get; set; } 17 | public int HitPoints { get; set; } 18 | public int ManaPoints { get; set; } 19 | public int Attack { get; set; } 20 | public int Defense { get; set; } 21 | public int Magic { get; set; } 22 | public int MagicDefense { get; set; } 23 | public int Agility { get; set; } 24 | public int Spirit { get; set; } 25 | public Guid CollectionId { get; set; } 26 | [ForeignKey("CollectionId")] 27 | [JsonIgnore] 28 | public Character Character { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Models/User.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | 4 | namespace Mog.Api.Core.Models 5 | { 6 | public class User 7 | { 8 | public string Id { get; set; } 9 | public string UserName { get; set; } 10 | public string Email { get; set; } 11 | public string FirstName { get; set; } 12 | public string LastName { get; set; } 13 | public string City { get; set; } 14 | public string State { get; set; } 15 | public string Country { get; set; } 16 | public DateTime? BirthDate { get; set; } 17 | public int Age { get; set; } 18 | public string Photo { get; set; } 19 | public string Wallpaper { get; set; } 20 | public string RoleName { get; set; } 21 | public DateTime JoinDate { get; set; } 22 | [JsonIgnore] 23 | public string Token { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Mog.Api.Core/Mog.Api.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | Mog.Api.Core 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Mog.Api.Core/Security/AppSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Mog.Api.Core.Security 2 | { 3 | public class AppSettings 4 | { 5 | public string Secret { get; set; } 6 | public string Issuer { get; set; } 7 | } 8 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Swagger/ConfigureSwaggerGenOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Reflection; 5 | using Microsoft.AspNetCore.Mvc.ApiExplorer; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.Extensions.Options; 8 | using Swashbuckle.AspNetCore.SwaggerGen; 9 | 10 | namespace Mog.Api.Core.Swagger 11 | { 12 | public sealed class ConfigureSwaggerGenOptions : IConfigureOptions 13 | { 14 | private readonly IApiVersionDescriptionProvider _provider; 15 | private readonly SwaggerSettings _settings; 16 | 17 | public ConfigureSwaggerGenOptions(IApiVersionDescriptionProvider versionDescriptionProvider, 18 | IOptions swaggerSettings) 19 | { 20 | Debug.Assert(versionDescriptionProvider != null, $"{nameof(versionDescriptionProvider)} != null"); 21 | Debug.Assert(swaggerSettings != null, $"{nameof(swaggerSettings)} != null"); 22 | 23 | _provider = versionDescriptionProvider; 24 | _settings = swaggerSettings.Value ?? new SwaggerSettings(); 25 | } 26 | 27 | public void Configure(SwaggerGenOptions options) 28 | { 29 | //options.DescribeAllEnumsAsStrings(); 30 | options.IgnoreObsoleteActions(); 31 | options.IgnoreObsoleteProperties(); 32 | 33 | AddSwaggerDocumentForEachDiscoveredApiVersion(options); 34 | SetCommentsPathForSwaggerJsonAndUi(options); 35 | //SetDefaultVersion(options); 36 | } 37 | 38 | private void SetDefaultVersion(SwaggerGenOptions options) 39 | { 40 | // This call removes version from parameter, without it we will have version as parameter 41 | // for all endpoints in swagger UI 42 | options.OperationFilter(); 43 | 44 | // This make replacement of v{version:apiVersion} to real version of corresponding swagger doc. 45 | options.DocumentFilter(); 46 | } 47 | 48 | private void AddSwaggerDocumentForEachDiscoveredApiVersion(SwaggerGenOptions options) 49 | { 50 | foreach (var description in _provider.ApiVersionDescriptions) 51 | { 52 | _settings.Info.Version = description.ApiVersion.ToString(); 53 | 54 | if (description.IsDeprecated) 55 | { 56 | _settings.Info.Description += " - DEPRECATED"; 57 | } 58 | 59 | options.SwaggerDoc(description.GroupName, _settings.Info); 60 | } 61 | } 62 | 63 | private static void SetCommentsPathForSwaggerJsonAndUi(SwaggerGenOptions options) 64 | { 65 | var xmlFile = $"{Assembly.GetEntryAssembly()?.GetName().Name}.xml"; 66 | var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); 67 | //options.IncludeXmlComments(xmlPath); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Mog.Api.Core/Swagger/ConfigureSwaggerOptions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Options; 2 | using Swashbuckle.AspNetCore.Swagger; 3 | 4 | namespace Mog.Api.Core.Swagger 5 | { 6 | public sealed class ConfigureSwaggerOptions : IConfigureOptions 7 | { 8 | private readonly SwaggerSettings _settings; 9 | 10 | public ConfigureSwaggerOptions(IOptions settings) 11 | { 12 | _settings = settings?.Value ?? new SwaggerSettings(); 13 | } 14 | 15 | public void Configure(SwaggerOptions options) 16 | { 17 | options.RouteTemplate = "swagger/{documentName}/swagger.json"; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Swagger/ConfigureSwaggerUiOptions.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Linq; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Mvc.ApiExplorer; 5 | using Microsoft.Extensions.Options; 6 | using Swashbuckle.AspNetCore.SwaggerUI; 7 | 8 | namespace Mog.Api.Core.Swagger 9 | { 10 | public sealed class ConfigureSwaggerUiOptions : IConfigureOptions 11 | { 12 | private readonly IApiVersionDescriptionProvider _provider; 13 | private readonly SwaggerSettings _settings; 14 | 15 | public ConfigureSwaggerUiOptions(IApiVersionDescriptionProvider versionDescriptionProvider, IOptions settings) 16 | { 17 | Debug.Assert(versionDescriptionProvider != null, $"{nameof(versionDescriptionProvider)} != null"); 18 | Debug.Assert(settings != null, $"{nameof(versionDescriptionProvider)} != null"); 19 | 20 | _provider = versionDescriptionProvider; 21 | _settings = settings?.Value ?? new SwaggerSettings(); 22 | } 23 | 24 | public void Configure(SwaggerUIOptions options) 25 | { 26 | _provider 27 | .ApiVersionDescriptions 28 | .ToList() 29 | .ForEach(description => 30 | { 31 | options.SwaggerEndpoint( 32 | $"./{description.GroupName}/swagger.json", 33 | description.GroupName.ToUpperInvariant()); 34 | }); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Mog.Api.Core/Swagger/RemoveVersionFromParameter.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Microsoft.OpenApi.Models; 3 | using Swashbuckle.AspNetCore.SwaggerGen; 4 | 5 | namespace Mog.Api.Core.Swagger 6 | { 7 | public class RemoveVersionFromParameter : IOperationFilter 8 | { 9 | public void Apply(OpenApiOperation operation, OperationFilterContext context) 10 | { 11 | var versionParameter = operation.Parameters.Single(p => p.Name == "description.GroupName"); 12 | operation.Parameters.Remove(versionParameter); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Swagger/ReplaceVersionWithExactValueInPath.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.OpenApi.Models; 2 | using Swashbuckle.AspNetCore.SwaggerGen; 3 | 4 | namespace Mog.Api.Core.Swagger 5 | { 6 | public class ReplaceVersionWithExactValueInPath : IDocumentFilter 7 | { 8 | public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) 9 | { 10 | var paths = new OpenApiPaths(); 11 | 12 | foreach (var x in swaggerDoc.Paths) 13 | { 14 | paths.Add(x.Key.Replace("{description.GroupName}", swaggerDoc.Info.Version), x.Value); 15 | } 16 | 17 | swaggerDoc.Paths = paths; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /Mog.Api.Core/Swagger/SwaggerSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.OpenApi.Models; 3 | 4 | namespace Mog.Api.Core.Swagger 5 | { 6 | public class SwaggerSettings 7 | { 8 | public SwaggerSettings() 9 | { 10 | Name = "MoogleApi"; 11 | Info = new OpenApiInfo 12 | { 13 | Title = "MoogleApi", 14 | Description = "A simple web API for Final Fantasy characters, monsters, and games!", 15 | Contact = new OpenApiContact 16 | { 17 | Name = "Jack F. Perry, Jr.", 18 | Email = "jackfperryjr@gmail.com", 19 | Url = new Uri("https://www.moogleapi.com") 20 | } 21 | }; 22 | } 23 | 24 | public string Name { get; set; } 25 | public OpenApiInfo Info { get; set; } 26 | } 27 | } -------------------------------------------------------------------------------- /Mog.Api.Core/WebApi/ApiControllerBase.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace Mog.Api.Core.WebApi 4 | { 5 | [ApiController] 6 | [Route("api/v{version:apiVersion}/[controller]s")] 7 | public abstract class ApiControllerBase : ControllerBase 8 | { } 9 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/AsheDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace Mog.Api.Infrastructure 4 | { 5 | public class AsheDbContext : DbContext 6 | { 7 | public AsheDbContext(DbContextOptions options) 8 | : base(options) 9 | { } 10 | 11 | public DbSet Blogs { get; set; } 12 | 13 | protected override void OnModelCreating(ModelBuilder builder) 14 | { 15 | base.OnModelCreating(builder); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/BlogFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using Mog.Api.Core.Abstractions; 7 | using Mog.Api.Core.Models; 8 | 9 | namespace Mog.Api.Infrastructure.Data 10 | { 11 | public class BlogFactory : IFactory, Guid> 12 | { 13 | private AsheDbContext _context; 14 | 15 | public BlogFactory( 16 | AsheDbContext context) 17 | { 18 | _context = context; 19 | } 20 | 21 | public async Task> GetAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 22 | { 23 | IQueryable blogs = _context.Blogs.OrderByDescending(x => x.Created); 24 | return blogs; 25 | } 26 | 27 | public async Task> GetByKeyAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 28 | { 29 | IQueryable blogs = _context.Blogs 30 | .Where(x => x.Id == id); 31 | return blogs; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/BlogReactionStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using System.Collections.Generic; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.Extensions.Configuration; 8 | using Mog.Api.Core.Abstractions; 9 | 10 | namespace Mog.Api.Infrastructure.Data 11 | { 12 | public class BlogReactionStore : IStore> 13 | { 14 | private AsheDbContext _context; 15 | private IConfiguration _configuration; 16 | private readonly IHttpContextAccessor _httpContextAccessor; 17 | 18 | public BlogReactionStore( 19 | AsheDbContext context, 20 | IConfiguration configuration, 21 | IHttpContextAccessor httpContextAccessor) 22 | { 23 | _context = context; 24 | _configuration = configuration; 25 | _httpContextAccessor = httpContextAccessor; 26 | } 27 | 28 | public async Task> AddAsync(KeyValuePair reaction, CancellationToken cancellationToken = new CancellationToken()) 29 | { 30 | return reaction; 31 | } 32 | 33 | public async Task> UpdateAsync(KeyValuePair reaction, CancellationToken cancellationToken = new CancellationToken()) 34 | { 35 | var blog = await _context.Blogs.FirstOrDefaultAsync(x => x.Id == reaction.Key); 36 | 37 | if (reaction.Value == "like") 38 | { 39 | blog.Like++; 40 | } 41 | 42 | if (reaction.Value == "dislike") 43 | { 44 | blog.Dislike++; 45 | } 46 | 47 | if (reaction.Value == "love") 48 | { 49 | blog.Love++; 50 | } 51 | 52 | _context.SaveChanges(); 53 | return reaction; 54 | } 55 | 56 | public async Task> DeleteAsync(KeyValuePair reaction, CancellationToken cancellationToken = new CancellationToken()) 57 | { 58 | return reaction; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/BlogStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using System.Collections.Generic; 6 | using System.Security.Claims; 7 | using Microsoft.EntityFrameworkCore; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.Configuration; 10 | using Mog.Api.Core.Extensions; 11 | using Mog.Api.Core.Abstractions; 12 | using Mog.Api.Core.Models; 13 | 14 | namespace Mog.Api.Infrastructure.Data 15 | { 16 | public class BlogStore : IStore 17 | { 18 | private AsheDbContext _context; 19 | private IConfiguration _configuration; 20 | private readonly IHttpContextAccessor _httpContextAccessor; 21 | 22 | public BlogStore( 23 | AsheDbContext context, 24 | IConfiguration configuration, 25 | IHttpContextAccessor httpContextAccessor) 26 | { 27 | _context = context; 28 | _configuration = configuration; 29 | _httpContextAccessor = httpContextAccessor; 30 | } 31 | 32 | public async Task AddAsync(Blog model, CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | model.Created = DateTimeOffset.Now; 35 | _context.Add(model); 36 | _context.SaveChanges(); 37 | var blog = _context.Blogs.Find(model.Id); 38 | 39 | return blog; 40 | } 41 | 42 | public async Task UpdateAsync(Blog model, CancellationToken cancellationToken = new CancellationToken()) 43 | { 44 | var blog = await _context.Blogs.FirstOrDefaultAsync(x => x.Id == model.Id); 45 | 46 | blog.Title = model.Title; 47 | blog.Content = model.Content; 48 | blog.Updated = DateTimeOffset.Now; 49 | _context.SaveChanges(); 50 | return model; 51 | } 52 | 53 | public async Task DeleteAsync(Blog model, CancellationToken cancellationToken = new CancellationToken()) 54 | { 55 | var blog = await _context.Blogs.FirstOrDefaultAsync(x => x.Id == model.Id); 56 | 57 | _context.Blogs.Remove(blog); 58 | _context.SaveChanges(); 59 | return model; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/CharacterFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using Mog.Api.Core.Abstractions; 7 | using Mog.Api.Core.Models; 8 | 9 | namespace Mog.Api.Infrastructure.Data 10 | { 11 | public class CharacterFactory : IFactory, Guid> 12 | { 13 | private SerahDbContext _context; 14 | 15 | public CharacterFactory( 16 | SerahDbContext context) 17 | { 18 | _context = context; 19 | } 20 | 21 | public async Task> GetAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 22 | { 23 | IQueryable characters = _context.Characters 24 | .Include(x => x.Pictures) 25 | .Include(x => x.Stats); 26 | characters = characters.OrderBy(x => x.Origin).ThenBy(x => x.Name); 27 | return characters; 28 | } 29 | 30 | public async Task> GetByKeyAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 31 | { 32 | IQueryable characters = _context.Characters 33 | .Include(x => x.Pictures) 34 | .Include(x => x.Stats) 35 | .Where(x => x.Id == id); 36 | return characters; 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/CharacterStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using System.Collections.Generic; 6 | using System.Security.Claims; 7 | using Microsoft.EntityFrameworkCore; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.Configuration; 10 | using Mog.Api.Core.Extensions; 11 | using Mog.Api.Core.Abstractions; 12 | using Mog.Api.Core.Models; 13 | 14 | namespace Mog.Api.Infrastructure.Data 15 | { 16 | public class CharacterStore : IStore 17 | { 18 | private SerahDbContext _context; 19 | private IConfiguration _configuration; 20 | private readonly IHttpContextAccessor _httpContextAccessor; 21 | 22 | public CharacterStore( 23 | SerahDbContext context, 24 | IConfiguration configuration, 25 | IHttpContextAccessor httpContextAccessor) 26 | { 27 | _context = context; 28 | _configuration = configuration; 29 | _httpContextAccessor = httpContextAccessor; 30 | } 31 | 32 | public async Task AddAsync(Character model, CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; 35 | var userName = claimsIdentity.FindFirst("sub")?.Value; 36 | 37 | var user = await ApplicationExtensions.Get(userName); 38 | 39 | _context.Add(model); 40 | _context.SaveChanges(); 41 | var character = _context.Characters.Find(model.Id); 42 | 43 | var feed = new Feed(); 44 | feed.UserName = user.UserName; 45 | feed.UserFirstName = user.FirstName; 46 | feed.UserPhoto = user.Photo; 47 | feed.CharacterName = model.Name; 48 | feed.CharacterId = model.Id; 49 | feed.TimeStamp = DateTime.Now; 50 | feed.Addition = 1; 51 | _context.Add(feed); 52 | _context.SaveChanges(); 53 | 54 | return character; 55 | } 56 | 57 | public async Task UpdateAsync(Character model, CancellationToken cancellationToken = new CancellationToken()) 58 | { 59 | var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; 60 | var userName = claimsIdentity.FindFirst("sub")?.Value; 61 | 62 | var user = await ApplicationExtensions.Get(userName); 63 | var character = await _context.Characters.FirstOrDefaultAsync(x => x.Id == model.Id); 64 | var feed = new Feed(); 65 | feed.UserName = user.UserName; 66 | feed.UserFirstName = user.FirstName; 67 | feed.UserPhoto = user.Photo; 68 | feed.CharacterName = model.Name; 69 | feed.CharacterId = model.Id; 70 | feed.TimeStamp = DateTime.Now; 71 | feed.Update = 1; 72 | _context.Add(feed); 73 | 74 | character.Name = model.Name; 75 | character.JapaneseName = model.JapaneseName; 76 | character.Age = model.Age; 77 | character.Gender = model.Gender; 78 | character.Race = model.Race; 79 | character.Job = model.Job; 80 | character.Height = model.Height; 81 | character.Weight = model.Weight; 82 | character.Origin = model.Origin; 83 | character.Description = model.Description; 84 | _context.SaveChanges(); 85 | return model; 86 | } 87 | 88 | public async Task DeleteAsync(Character model, CancellationToken cancellationToken = new CancellationToken()) 89 | { 90 | var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; 91 | var userName = claimsIdentity.FindFirst("sub")?.Value; 92 | 93 | var user = await ApplicationExtensions.Get(userName); 94 | var feed = new Feed(); 95 | feed.UserName = user.UserName; 96 | feed.UserFirstName = user.FirstName; 97 | feed.UserPhoto = user.Photo; 98 | feed.CharacterName = model.Name; 99 | feed.CharacterId = model.Id; 100 | feed.TimeStamp = DateTime.Now; 101 | feed.Deletion = 1; 102 | feed.StatDeletion = 1; 103 | _context.Add(feed); 104 | 105 | var character = await _context.Characters.FirstOrDefaultAsync(x => x.Id == model.Id); 106 | var stats = await _context.Stats.Where(x => x.CollectionId == model.Id).ToListAsync(); 107 | var pictures = await _context.Pictures.Where(x => x.CollectionId == model.Id).ToListAsync(); 108 | var profile = await _context.DatingProfile.FirstOrDefaultAsync(x => x.CharacterId == model.Id); 109 | IList responses; 110 | 111 | if (profile != null) 112 | { 113 | responses = await _context.Responses.Where(x => x.DatingProfileId == profile.Id).ToListAsync(); 114 | _context.Responses.RemoveRange(responses); 115 | _context.DatingProfile.Remove(profile); 116 | } 117 | 118 | _context.Stats.RemoveRange(stats); 119 | _context.Pictures.RemoveRange(pictures); 120 | _context.Characters.Remove(character); 121 | _context.SaveChanges(); 122 | return model; 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/DatingProfileFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.EntityFrameworkCore; 6 | using Mog.Api.Core.Abstractions; 7 | using Mog.Api.Core.Models; 8 | 9 | namespace Mog.Api.Infrastructure.Data 10 | { 11 | public class DatingProfileFactory : IFactory, Guid> 12 | { 13 | private SerahDbContext _context; 14 | 15 | public DatingProfileFactory( 16 | SerahDbContext context) 17 | { 18 | _context = context; 19 | } 20 | 21 | public async Task> GetAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 22 | { 23 | IQueryable datingProfiles = _context.DatingProfile 24 | .Include(x => x.Responses) 25 | .Include(x => x.Character) 26 | .ThenInclude(x => x.Pictures); 27 | datingProfiles = datingProfiles.OrderBy(x => x.Character.Name); 28 | return datingProfiles; 29 | } 30 | 31 | public async Task> GetByKeyAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 32 | { 33 | IQueryable datingProfiles = _context.DatingProfile 34 | .Include(x => x.Responses) 35 | .Include(x => x.Character) 36 | .ThenInclude(x => x.Pictures) 37 | .Where(x => x.CharacterId == id); 38 | return datingProfiles; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/FeedFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Mog.Api.Core.Abstractions; 6 | using Mog.Api.Core.Models; 7 | 8 | namespace Mog.Api.Infrastructure.Data 9 | { 10 | public class FeedFactory : IFactory, Guid> 11 | { 12 | private SerahDbContext _context; 13 | 14 | public FeedFactory( 15 | SerahDbContext context) 16 | { 17 | _context = context; 18 | } 19 | 20 | public async Task> GetAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 21 | { 22 | IQueryable feed = _context.Feed; 23 | feed = feed.OrderByDescending(x => x.TimeStamp); 24 | foreach (var x in feed) 25 | { 26 | DateTime convertedDate = DateTime.SpecifyKind(x.TimeStamp, DateTimeKind.Utc); 27 | x.TimeStamp = convertedDate.ToLocalTime(); 28 | } 29 | 30 | return feed; 31 | } 32 | 33 | public async Task> GetByKeyAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 34 | { 35 | throw new NotImplementedException(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/FeedStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Microsoft.EntityFrameworkCore; 5 | using Microsoft.AspNetCore.Http; 6 | using Microsoft.Extensions.Configuration; 7 | using Mog.Api.Core.Abstractions; 8 | 9 | namespace Mog.Api.Infrastructure.Data 10 | { 11 | public class FeedStore : IStore 12 | { 13 | private SerahDbContext _context; 14 | private IConfiguration _configuration; 15 | private readonly IHttpContextAccessor _httpContextAccessor; 16 | 17 | public FeedStore( 18 | SerahDbContext context, 19 | IConfiguration configuration, 20 | IHttpContextAccessor httpContextAccessor) 21 | { 22 | _context = context; 23 | _configuration = configuration; 24 | _httpContextAccessor = httpContextAccessor; 25 | } 26 | 27 | public async Task AddAsync(object[] reaction, CancellationToken cancellationToken = new CancellationToken()) 28 | { 29 | return reaction; 30 | } 31 | 32 | public async Task UpdateAsync(object[] reaction, CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | var feed = await _context.Feed.FirstOrDefaultAsync(x => x.Id == new Guid(reaction[0].ToString())); 35 | 36 | if (reaction[1].ToString() == "like") 37 | { 38 | feed.Like++; 39 | } 40 | 41 | if (reaction[1].ToString() == "dislike") 42 | { 43 | feed.Dislike++; 44 | } 45 | 46 | if (reaction[1].ToString() == "love") 47 | { 48 | feed.Love++; 49 | } 50 | 51 | _context.SaveChanges(); 52 | return reaction; 53 | } 54 | 55 | public async Task DeleteAsync(object[] reaction, CancellationToken cancellationToken = new CancellationToken()) 56 | { 57 | return reaction; 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/GameFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Mog.Api.Core.Abstractions; 6 | using Mog.Api.Core.Models; 7 | 8 | namespace Mog.Api.Infrastructure.Data 9 | { 10 | public class GameFactory : IFactory, Guid> 11 | { 12 | private SerahDbContext _context; 13 | 14 | public GameFactory( 15 | SerahDbContext context) 16 | { 17 | _context = context; 18 | } 19 | 20 | public async Task> GetAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 21 | { 22 | IQueryable games = _context.Games; 23 | games = games.OrderBy(x => x.Title); 24 | return games; 25 | } 26 | 27 | public async Task> GetByKeyAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 28 | { 29 | 30 | IQueryable games = _context.Games.Where(x => x.GameId == id); 31 | return games; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/MonsterFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Mog.Api.Core.Abstractions; 6 | using Mog.Api.Core.Models; 7 | 8 | namespace Mog.Api.Infrastructure.Data 9 | { 10 | public class MonsterFactory : IFactory, Guid> 11 | { 12 | private SerahDbContext _context; 13 | 14 | public MonsterFactory( 15 | SerahDbContext context) 16 | { 17 | _context = context; 18 | } 19 | 20 | public async Task> GetAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 21 | { 22 | IQueryable monsters = _context.Monsters; 23 | monsters = monsters.OrderBy(x => x.Name); 24 | return monsters; 25 | } 26 | 27 | public async Task> GetByKeyAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 28 | { 29 | 30 | IQueryable monsters = _context.Monsters.Where(x => x.MonsterId == id); 31 | return monsters; 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/PictureStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | using System.Security.Claims; 7 | using Microsoft.EntityFrameworkCore; 8 | using Microsoft.AspNetCore.Http; 9 | using Microsoft.Extensions.Configuration; 10 | using Mog.Api.Core.Extensions; 11 | using Mog.Api.Core.Abstractions; 12 | using Mog.Api.Core.Models; 13 | 14 | namespace Mog.Api.Infrastructure.Data 15 | { 16 | public class PictureStore : IStore 17 | { 18 | private SerahDbContext _context; 19 | private IConfiguration _configuration; 20 | private readonly IHttpContextAccessor _httpContextAccessor; 21 | 22 | public PictureStore( 23 | SerahDbContext context, 24 | IConfiguration configuration, 25 | IHttpContextAccessor httpContextAccessor) 26 | { 27 | _context = context; 28 | _configuration = configuration; 29 | _httpContextAccessor = httpContextAccessor; 30 | } 31 | 32 | public async Task AddAsync(Picture model, CancellationToken cancellationToken = new CancellationToken()) 33 | { 34 | //This container is used for blob storage uploads. 35 | var container = ApplicationExtensions.ConfigureBlobContainer( 36 | _configuration["AzureStorageConfig:AccountName"], 37 | _configuration["AzureStorageConfig:AccountKey"]); 38 | await container.CreateIfNotExistsAsync(); 39 | 40 | _context.Add(model); 41 | _context.SaveChanges(); 42 | var picture = _context.Pictures.Find(model.Id); 43 | var files = _httpContextAccessor.HttpContext.Request.Form.Files; 44 | 45 | if (files.Count != 0) 46 | { 47 | for (var i = 0; i < files.Count; i++) 48 | { 49 | if (files[i].Name == "photo") 50 | { 51 | var newBlob = container.GetBlockBlobReference(picture.Id + ".jpg"); 52 | 53 | using (var filestream = new MemoryStream()) 54 | { 55 | files[i].CopyTo(filestream); 56 | filestream.Position = 0; 57 | await newBlob.UploadFromStreamAsync(filestream); 58 | } 59 | 60 | picture.Url = "https://mooglestorage.blob.core.windows.net/images/" + picture.Id + ".jpg"; 61 | } 62 | } 63 | } 64 | 65 | var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; 66 | var userName = claimsIdentity.FindFirst("sub")?.Value; 67 | 68 | var user = await ApplicationExtensions.Get(userName); 69 | var character = await _context.Characters.FirstOrDefaultAsync(x => x.Id == model.Id); 70 | var feed = new Feed(); 71 | feed.UserName = user.UserName; 72 | feed.UserFirstName = user.FirstName; 73 | feed.UserPhoto = user.Photo; 74 | feed.CharacterName = character.Name; 75 | feed.CharacterId = character.Id; 76 | feed.TimeStamp = DateTime.Now; 77 | feed.PhotoUpdate = 1; 78 | _context.Add(feed); 79 | _context.SaveChanges(); 80 | return picture; 81 | } 82 | 83 | public async Task UpdateAsync(Picture model, CancellationToken cancellationToken = new CancellationToken()) 84 | { 85 | //This container is used for blob storage uploads. 86 | var container = ApplicationExtensions.ConfigureBlobContainer( 87 | _configuration["AzureStorageConfig:AccountName"], 88 | _configuration["AzureStorageConfig:AccountKey"]); 89 | await container.CreateIfNotExistsAsync(); 90 | 91 | _context.Pictures.RemoveRange(_context.Pictures.Where(x => x.CollectionId == model.CollectionId)); 92 | _context.SaveChanges(); 93 | model.Id = Guid.NewGuid(); 94 | _context.Add(model); 95 | _context.SaveChanges(); 96 | var picture = _context.Pictures.Find(model.Id); 97 | var files = _httpContextAccessor.HttpContext.Request.Form.Files; 98 | 99 | if (files.Count != 0) 100 | { 101 | for (var i = 0; i < files.Count; i++) 102 | { 103 | if (files[i].Name == "photo") 104 | { 105 | var newBlob = container.GetBlockBlobReference(picture.Id + ".jpg"); 106 | 107 | using (var filestream = new MemoryStream()) 108 | { 109 | files[i].CopyTo(filestream); 110 | filestream.Position = 0; 111 | await newBlob.UploadFromStreamAsync(filestream); 112 | } 113 | 114 | picture.Url = "https://mooglestorage.blob.core.windows.net/images/" + picture.Id + ".jpg"; 115 | } 116 | } 117 | } 118 | 119 | var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; 120 | var userName = claimsIdentity.FindFirst("sub")?.Value; 121 | 122 | var user = await ApplicationExtensions.Get(userName); 123 | var character = await _context.Characters.FirstOrDefaultAsync(x => x.Id == model.CollectionId); 124 | var feed = new Feed(); 125 | feed.UserName = user.UserName; 126 | feed.UserFirstName = user.FirstName; 127 | feed.UserPhoto = user.Photo; 128 | feed.CharacterName = character.Name; 129 | feed.CharacterId = character.Id; 130 | feed.TimeStamp = DateTime.Now; 131 | feed.PhotoUpdate = 1; 132 | _context.Add(feed); 133 | _context.SaveChanges(); 134 | return model; 135 | } 136 | 137 | public async Task DeleteAsync(Picture model, CancellationToken cancellationToken = new CancellationToken()) 138 | { 139 | throw new NotImplementedException(); 140 | } 141 | } 142 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/StatFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Mog.Api.Core.Abstractions; 6 | using Mog.Api.Core.Models; 7 | 8 | namespace Mog.Api.Infrastructure.Data 9 | { 10 | public class StatFactory : IFactory, Guid> 11 | { 12 | private SerahDbContext _context; 13 | 14 | public StatFactory( 15 | SerahDbContext context) 16 | { 17 | _context = context; 18 | } 19 | 20 | public async Task> GetAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 21 | { 22 | IQueryable stats = _context.Stats; 23 | stats = stats.OrderBy(x => x.Platform); 24 | return stats; 25 | } 26 | 27 | public async Task> GetByKeyAsync(Guid id, CancellationToken cancellationToken = default(CancellationToken)) 28 | { 29 | IQueryable stats = _context.Stats.Where(x => x.Id == id); 30 | return stats; 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Data/StatStore.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using System.Security.Claims; 5 | using Microsoft.EntityFrameworkCore; 6 | using Microsoft.AspNetCore.Http; 7 | using Microsoft.Extensions.Configuration; 8 | using Mog.Api.Core.Extensions; 9 | using Mog.Api.Core.Abstractions; 10 | using Mog.Api.Core.Models; 11 | 12 | namespace Mog.Api.Infrastructure.Data 13 | { 14 | public class StatStore : IStore 15 | { 16 | private SerahDbContext _context; 17 | private IConfiguration _configuration; 18 | private readonly IHttpContextAccessor _httpContextAccessor; 19 | 20 | public StatStore( 21 | SerahDbContext context, 22 | IConfiguration configuration, 23 | IHttpContextAccessor httpContextAccessor) 24 | { 25 | _context = context; 26 | _configuration = configuration; 27 | _httpContextAccessor = httpContextAccessor; 28 | } 29 | 30 | public async Task AddAsync(Stat model, CancellationToken cancellationToken = new CancellationToken()) 31 | { 32 | var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; 33 | var userName = claimsIdentity.FindFirst("sub")?.Value; 34 | 35 | var user = await ApplicationExtensions.Get(userName); 36 | var character = await _context.Characters.FirstOrDefaultAsync(x => x.Id == model.Id); 37 | var feed = new Feed(); 38 | feed.UserName = user.UserName; 39 | feed.UserFirstName = user.FirstName; 40 | feed.UserPhoto = user.Photo; 41 | feed.CharacterName = character.Name; 42 | feed.CharacterId = character.Id; 43 | feed.TimeStamp = DateTime.Now; 44 | feed.StatAddition = 1; 45 | _context.Add(feed); 46 | 47 | _context.Add(model); 48 | _context.SaveChanges(); 49 | return model; 50 | } 51 | 52 | public async Task UpdateAsync(Stat model, CancellationToken cancellationToken = new CancellationToken()) 53 | { 54 | var stat = await _context.Stats.FirstOrDefaultAsync(x => x.Id == model.Id); 55 | var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; 56 | var userName = claimsIdentity.FindFirst("sub")?.Value; 57 | 58 | var user = await ApplicationExtensions.Get(userName); 59 | var character = await _context.Characters.FirstOrDefaultAsync(x => x.Id == model.Id); 60 | var feed = new Feed(); 61 | feed.UserName = user.UserName; 62 | feed.UserFirstName = user.FirstName; 63 | feed.UserPhoto = user.Photo; 64 | feed.CharacterName = character.Name; 65 | feed.CharacterId = character.Id; 66 | feed.TimeStamp = DateTime.Now; 67 | feed.StatUpdate = 1; 68 | _context.Add(feed); 69 | 70 | stat.Platform = model.Platform; 71 | stat.Class = model.Class; 72 | stat.Level = model.Level; 73 | stat.HitPoints = model.HitPoints; 74 | stat.ManaPoints = model.ManaPoints; 75 | stat.Attack = model.Attack; 76 | stat.Defense = model.Defense; 77 | stat.Magic = model.Magic; 78 | stat.MagicDefense = model.MagicDefense; 79 | stat.Agility = model.Agility; 80 | stat.Spirit = model.Spirit; 81 | _context.SaveChanges(); 82 | return model; 83 | } 84 | 85 | public async Task DeleteAsync(Stat model, CancellationToken cancellationToken = new CancellationToken()) 86 | { 87 | var stat = await _context.Stats.FirstOrDefaultAsync(x => x.Id == model.Id); 88 | var claimsIdentity = _httpContextAccessor.HttpContext.User.Identity as ClaimsIdentity; 89 | var userName = claimsIdentity.FindFirst("sub")?.Value; 90 | 91 | var user = await ApplicationExtensions.Get(userName); 92 | var character = await _context.Characters.FirstOrDefaultAsync(x => x.Id == model.Id); 93 | var feed = new Feed(); 94 | feed.UserName = user.UserName; 95 | feed.UserFirstName = user.FirstName; 96 | feed.UserPhoto = user.Photo; 97 | feed.CharacterName = character.Name; 98 | feed.CharacterId = character.Id; 99 | feed.TimeStamp = DateTime.Now; 100 | feed.StatDeletion = 1; 101 | _context.Add(feed); 102 | 103 | _context.Stats.Remove(stat); 104 | _context.SaveChanges(); 105 | return model; 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/20200709124158_Initial.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using Mog.Api.Infrastructure; 9 | 10 | namespace Mog.Api.Infrastructure.Migrations 11 | { 12 | [DbContext(typeof(SerahDbContext))] 13 | [Migration("20200709124158_Initial")] 14 | partial class Initial 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "3.1.0") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("Mog.Api.Core.Models.Character", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("uniqueidentifier"); 29 | 30 | b.Property("Age") 31 | .IsRequired() 32 | .HasColumnType("nvarchar(max)"); 33 | 34 | b.Property("Description") 35 | .HasColumnType("nvarchar(max)"); 36 | 37 | b.Property("Gender") 38 | .IsRequired() 39 | .HasColumnType("nvarchar(max)"); 40 | 41 | b.Property("Height") 42 | .HasColumnType("nvarchar(max)"); 43 | 44 | b.Property("JapaneseName") 45 | .HasColumnType("nvarchar(max)"); 46 | 47 | b.Property("Job") 48 | .IsRequired() 49 | .HasColumnType("nvarchar(max)"); 50 | 51 | b.Property("Name") 52 | .IsRequired() 53 | .HasColumnType("nvarchar(max)"); 54 | 55 | b.Property("Origin") 56 | .IsRequired() 57 | .HasColumnType("nvarchar(max)"); 58 | 59 | b.Property("Race") 60 | .IsRequired() 61 | .HasColumnType("nvarchar(max)"); 62 | 63 | b.Property("Weight") 64 | .HasColumnType("nvarchar(max)"); 65 | 66 | b.HasKey("Id"); 67 | 68 | b.ToTable("Characters"); 69 | }); 70 | 71 | modelBuilder.Entity("Mog.Api.Core.Models.DatingProfile", b => 72 | { 73 | b.Property("Id") 74 | .ValueGeneratedOnAdd() 75 | .HasColumnType("uniqueidentifier"); 76 | 77 | b.Property("Age") 78 | .HasColumnType("nvarchar(max)"); 79 | 80 | b.Property("Bio") 81 | .HasColumnType("nvarchar(max)"); 82 | 83 | b.Property("CharacterId") 84 | .HasColumnType("uniqueidentifier"); 85 | 86 | b.Property("Gender") 87 | .HasColumnType("nvarchar(max)"); 88 | 89 | b.HasKey("Id"); 90 | 91 | b.HasIndex("CharacterId"); 92 | 93 | b.ToTable("DatingProfile"); 94 | }); 95 | 96 | modelBuilder.Entity("Mog.Api.Core.Models.DatingResponse", b => 97 | { 98 | b.Property("Id") 99 | .ValueGeneratedOnAdd() 100 | .HasColumnType("uniqueidentifier"); 101 | 102 | b.Property("DatingProfileId") 103 | .HasColumnType("uniqueidentifier"); 104 | 105 | b.Property("Response") 106 | .HasColumnType("nvarchar(max)"); 107 | 108 | b.HasKey("Id"); 109 | 110 | b.HasIndex("DatingProfileId"); 111 | 112 | b.ToTable("Responses"); 113 | }); 114 | 115 | modelBuilder.Entity("Mog.Api.Core.Models.Game", b => 116 | { 117 | b.Property("GameId") 118 | .ValueGeneratedOnAdd() 119 | .HasColumnType("uniqueidentifier"); 120 | 121 | b.Property("Description") 122 | .HasColumnType("nvarchar(max)"); 123 | 124 | b.Property("Picture") 125 | .HasColumnType("nvarchar(max)"); 126 | 127 | b.Property("Platform") 128 | .HasColumnType("nvarchar(max)"); 129 | 130 | b.Property("ReleaseDate") 131 | .HasColumnType("nvarchar(max)"); 132 | 133 | b.Property("Title") 134 | .IsRequired() 135 | .HasColumnType("nvarchar(max)"); 136 | 137 | b.HasKey("GameId"); 138 | 139 | b.ToTable("Games"); 140 | }); 141 | 142 | modelBuilder.Entity("Mog.Api.Core.Models.Monster", b => 143 | { 144 | b.Property("MonsterId") 145 | .ValueGeneratedOnAdd() 146 | .HasColumnType("uniqueidentifier"); 147 | 148 | b.Property("AddedBy") 149 | .HasColumnType("nvarchar(max)"); 150 | 151 | b.Property("Attack") 152 | .HasColumnType("int"); 153 | 154 | b.Property("Defense") 155 | .HasColumnType("int"); 156 | 157 | b.Property("Description") 158 | .HasColumnType("nvarchar(max)"); 159 | 160 | b.Property("ElementalAffinity") 161 | .HasColumnType("nvarchar(max)"); 162 | 163 | b.Property("ElementalWeakness") 164 | .HasColumnType("nvarchar(max)"); 165 | 166 | b.Property("Game") 167 | .HasColumnType("nvarchar(max)"); 168 | 169 | b.Property("HitPoints") 170 | .HasColumnType("int"); 171 | 172 | b.Property("JapaneseName") 173 | .HasColumnType("nvarchar(max)"); 174 | 175 | b.Property("ManaPoints") 176 | .HasColumnType("int"); 177 | 178 | b.Property("Name") 179 | .IsRequired() 180 | .HasColumnType("nvarchar(max)"); 181 | 182 | b.Property("Picture") 183 | .HasColumnType("nvarchar(max)"); 184 | 185 | b.HasKey("MonsterId"); 186 | 187 | b.ToTable("Monsters"); 188 | }); 189 | 190 | modelBuilder.Entity("Mog.Api.Core.Models.Picture", b => 191 | { 192 | b.Property("Id") 193 | .ValueGeneratedOnAdd() 194 | .HasColumnType("uniqueidentifier"); 195 | 196 | b.Property("CollectionId") 197 | .HasColumnType("uniqueidentifier"); 198 | 199 | b.Property("Primary") 200 | .HasColumnType("int"); 201 | 202 | b.Property("Url") 203 | .HasColumnType("nvarchar(max)"); 204 | 205 | b.HasKey("Id"); 206 | 207 | b.HasIndex("CollectionId"); 208 | 209 | b.ToTable("Pictures"); 210 | }); 211 | 212 | modelBuilder.Entity("Mog.Api.Core.Models.Stat", b => 213 | { 214 | b.Property("Id") 215 | .ValueGeneratedOnAdd() 216 | .HasColumnType("uniqueidentifier"); 217 | 218 | b.Property("Agility") 219 | .HasColumnType("int"); 220 | 221 | b.Property("Attack") 222 | .HasColumnType("int"); 223 | 224 | b.Property("CollectionId") 225 | .HasColumnType("uniqueidentifier"); 226 | 227 | b.Property("Defense") 228 | .HasColumnType("int"); 229 | 230 | b.Property("HitPoints") 231 | .HasColumnType("int"); 232 | 233 | b.Property("Magic") 234 | .HasColumnType("int"); 235 | 236 | b.Property("MagicDefense") 237 | .HasColumnType("int"); 238 | 239 | b.Property("ManaPoints") 240 | .HasColumnType("int"); 241 | 242 | b.Property("Platform") 243 | .HasColumnType("nvarchar(max)"); 244 | 245 | b.Property("Spirit") 246 | .HasColumnType("int"); 247 | 248 | b.HasKey("Id"); 249 | 250 | b.HasIndex("CollectionId"); 251 | 252 | b.ToTable("Stats"); 253 | }); 254 | 255 | modelBuilder.Entity("Mog.Api.Core.Models.DatingProfile", b => 256 | { 257 | b.HasOne("Mog.Api.Core.Models.Character", "Character") 258 | .WithMany() 259 | .HasForeignKey("CharacterId") 260 | .OnDelete(DeleteBehavior.Cascade) 261 | .IsRequired(); 262 | }); 263 | 264 | modelBuilder.Entity("Mog.Api.Core.Models.DatingResponse", b => 265 | { 266 | b.HasOne("Mog.Api.Core.Models.DatingProfile", "DatingProfile") 267 | .WithMany("Responses") 268 | .HasForeignKey("DatingProfileId") 269 | .OnDelete(DeleteBehavior.Cascade) 270 | .IsRequired(); 271 | }); 272 | 273 | modelBuilder.Entity("Mog.Api.Core.Models.Picture", b => 274 | { 275 | b.HasOne("Mog.Api.Core.Models.Character", "Character") 276 | .WithMany("Pictures") 277 | .HasForeignKey("CollectionId") 278 | .OnDelete(DeleteBehavior.Cascade) 279 | .IsRequired(); 280 | }); 281 | 282 | modelBuilder.Entity("Mog.Api.Core.Models.Stat", b => 283 | { 284 | b.HasOne("Mog.Api.Core.Models.Character", "Character") 285 | .WithMany("Stats") 286 | .HasForeignKey("CollectionId") 287 | .OnDelete(DeleteBehavior.Cascade) 288 | .IsRequired(); 289 | }); 290 | #pragma warning restore 612, 618 291 | } 292 | } 293 | } 294 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/20200709124158_Initial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace Mog.Api.Infrastructure.Migrations 5 | { 6 | public partial class Initial : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.AddColumn( 11 | name: "JapaneseName", 12 | table: "Characters", 13 | nullable: true); 14 | } 15 | 16 | protected override void Down(MigrationBuilder migrationBuilder) 17 | { 18 | migrationBuilder.DropColumn( 19 | name: "JapaneseName", 20 | table: "Characters"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/20200818221511_NewPropsToStats.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using Mog.Api.Infrastructure; 9 | 10 | namespace Mog.Api.Infrastructure.Migrations 11 | { 12 | [DbContext(typeof(SerahDbContext))] 13 | [Migration("20200818221511_NewPropsToStats")] 14 | partial class NewPropsToStats 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("ProductVersion", "3.1.0") 21 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("Mog.Api.Core.Models.Character", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("uniqueidentifier"); 29 | 30 | b.Property("Age") 31 | .IsRequired() 32 | .HasColumnType("nvarchar(max)"); 33 | 34 | b.Property("Description") 35 | .HasColumnType("nvarchar(max)"); 36 | 37 | b.Property("Gender") 38 | .IsRequired() 39 | .HasColumnType("nvarchar(max)"); 40 | 41 | b.Property("Height") 42 | .HasColumnType("nvarchar(max)"); 43 | 44 | b.Property("JapaneseName") 45 | .HasColumnType("nvarchar(max)"); 46 | 47 | b.Property("Job") 48 | .IsRequired() 49 | .HasColumnType("nvarchar(max)"); 50 | 51 | b.Property("Name") 52 | .IsRequired() 53 | .HasColumnType("nvarchar(max)"); 54 | 55 | b.Property("Origin") 56 | .IsRequired() 57 | .HasColumnType("nvarchar(max)"); 58 | 59 | b.Property("Race") 60 | .IsRequired() 61 | .HasColumnType("nvarchar(max)"); 62 | 63 | b.Property("Weight") 64 | .HasColumnType("nvarchar(max)"); 65 | 66 | b.HasKey("Id"); 67 | 68 | b.ToTable("Characters"); 69 | }); 70 | 71 | modelBuilder.Entity("Mog.Api.Core.Models.DatingProfile", b => 72 | { 73 | b.Property("Id") 74 | .ValueGeneratedOnAdd() 75 | .HasColumnType("uniqueidentifier"); 76 | 77 | b.Property("Age") 78 | .HasColumnType("nvarchar(max)"); 79 | 80 | b.Property("Bio") 81 | .HasColumnType("nvarchar(max)"); 82 | 83 | b.Property("CharacterId") 84 | .HasColumnType("uniqueidentifier"); 85 | 86 | b.Property("Gender") 87 | .HasColumnType("nvarchar(max)"); 88 | 89 | b.HasKey("Id"); 90 | 91 | b.HasIndex("CharacterId"); 92 | 93 | b.ToTable("DatingProfile"); 94 | }); 95 | 96 | modelBuilder.Entity("Mog.Api.Core.Models.DatingResponse", b => 97 | { 98 | b.Property("Id") 99 | .ValueGeneratedOnAdd() 100 | .HasColumnType("uniqueidentifier"); 101 | 102 | b.Property("DatingProfileId") 103 | .HasColumnType("uniqueidentifier"); 104 | 105 | b.Property("Response") 106 | .HasColumnType("nvarchar(max)"); 107 | 108 | b.HasKey("Id"); 109 | 110 | b.HasIndex("DatingProfileId"); 111 | 112 | b.ToTable("Responses"); 113 | }); 114 | 115 | modelBuilder.Entity("Mog.Api.Core.Models.Game", b => 116 | { 117 | b.Property("GameId") 118 | .ValueGeneratedOnAdd() 119 | .HasColumnType("uniqueidentifier"); 120 | 121 | b.Property("Description") 122 | .HasColumnType("nvarchar(max)"); 123 | 124 | b.Property("Picture") 125 | .HasColumnType("nvarchar(max)"); 126 | 127 | b.Property("Platform") 128 | .HasColumnType("nvarchar(max)"); 129 | 130 | b.Property("ReleaseDate") 131 | .HasColumnType("nvarchar(max)"); 132 | 133 | b.Property("Title") 134 | .IsRequired() 135 | .HasColumnType("nvarchar(max)"); 136 | 137 | b.HasKey("GameId"); 138 | 139 | b.ToTable("Games"); 140 | }); 141 | 142 | modelBuilder.Entity("Mog.Api.Core.Models.Monster", b => 143 | { 144 | b.Property("MonsterId") 145 | .ValueGeneratedOnAdd() 146 | .HasColumnType("uniqueidentifier"); 147 | 148 | b.Property("AddedBy") 149 | .HasColumnType("nvarchar(max)"); 150 | 151 | b.Property("Attack") 152 | .HasColumnType("int"); 153 | 154 | b.Property("Defense") 155 | .HasColumnType("int"); 156 | 157 | b.Property("Description") 158 | .HasColumnType("nvarchar(max)"); 159 | 160 | b.Property("ElementalAffinity") 161 | .HasColumnType("nvarchar(max)"); 162 | 163 | b.Property("ElementalWeakness") 164 | .HasColumnType("nvarchar(max)"); 165 | 166 | b.Property("Game") 167 | .HasColumnType("nvarchar(max)"); 168 | 169 | b.Property("HitPoints") 170 | .HasColumnType("int"); 171 | 172 | b.Property("JapaneseName") 173 | .HasColumnType("nvarchar(max)"); 174 | 175 | b.Property("ManaPoints") 176 | .HasColumnType("int"); 177 | 178 | b.Property("Name") 179 | .IsRequired() 180 | .HasColumnType("nvarchar(max)"); 181 | 182 | b.Property("Picture") 183 | .HasColumnType("nvarchar(max)"); 184 | 185 | b.HasKey("MonsterId"); 186 | 187 | b.ToTable("Monsters"); 188 | }); 189 | 190 | modelBuilder.Entity("Mog.Api.Core.Models.Picture", b => 191 | { 192 | b.Property("Id") 193 | .ValueGeneratedOnAdd() 194 | .HasColumnType("uniqueidentifier"); 195 | 196 | b.Property("CollectionId") 197 | .HasColumnType("uniqueidentifier"); 198 | 199 | b.Property("Primary") 200 | .HasColumnType("int"); 201 | 202 | b.Property("Url") 203 | .HasColumnType("nvarchar(max)"); 204 | 205 | b.HasKey("Id"); 206 | 207 | b.HasIndex("CollectionId"); 208 | 209 | b.ToTable("Pictures"); 210 | }); 211 | 212 | modelBuilder.Entity("Mog.Api.Core.Models.Stat", b => 213 | { 214 | b.Property("Id") 215 | .ValueGeneratedOnAdd() 216 | .HasColumnType("uniqueidentifier"); 217 | 218 | b.Property("Agility") 219 | .HasColumnType("int"); 220 | 221 | b.Property("Attack") 222 | .HasColumnType("int"); 223 | 224 | b.Property("Class") 225 | .HasColumnType("nvarchar(max)"); 226 | 227 | b.Property("CollectionId") 228 | .HasColumnType("uniqueidentifier"); 229 | 230 | b.Property("Defense") 231 | .HasColumnType("int"); 232 | 233 | b.Property("HitPoints") 234 | .HasColumnType("int"); 235 | 236 | b.Property("Level") 237 | .HasColumnType("int"); 238 | 239 | b.Property("Magic") 240 | .HasColumnType("int"); 241 | 242 | b.Property("MagicDefense") 243 | .HasColumnType("int"); 244 | 245 | b.Property("ManaPoints") 246 | .HasColumnType("int"); 247 | 248 | b.Property("Platform") 249 | .HasColumnType("nvarchar(max)"); 250 | 251 | b.Property("Spirit") 252 | .HasColumnType("int"); 253 | 254 | b.HasKey("Id"); 255 | 256 | b.HasIndex("CollectionId"); 257 | 258 | b.ToTable("Stats"); 259 | }); 260 | 261 | modelBuilder.Entity("Mog.Api.Core.Models.DatingProfile", b => 262 | { 263 | b.HasOne("Mog.Api.Core.Models.Character", "Character") 264 | .WithMany() 265 | .HasForeignKey("CharacterId") 266 | .OnDelete(DeleteBehavior.Cascade) 267 | .IsRequired(); 268 | }); 269 | 270 | modelBuilder.Entity("Mog.Api.Core.Models.DatingResponse", b => 271 | { 272 | b.HasOne("Mog.Api.Core.Models.DatingProfile", "DatingProfile") 273 | .WithMany("Responses") 274 | .HasForeignKey("DatingProfileId") 275 | .OnDelete(DeleteBehavior.Cascade) 276 | .IsRequired(); 277 | }); 278 | 279 | modelBuilder.Entity("Mog.Api.Core.Models.Picture", b => 280 | { 281 | b.HasOne("Mog.Api.Core.Models.Character", "Character") 282 | .WithMany("Pictures") 283 | .HasForeignKey("CollectionId") 284 | .OnDelete(DeleteBehavior.Cascade) 285 | .IsRequired(); 286 | }); 287 | 288 | modelBuilder.Entity("Mog.Api.Core.Models.Stat", b => 289 | { 290 | b.HasOne("Mog.Api.Core.Models.Character", "Character") 291 | .WithMany("Stats") 292 | .HasForeignKey("CollectionId") 293 | .OnDelete(DeleteBehavior.Cascade) 294 | .IsRequired(); 295 | }); 296 | #pragma warning restore 612, 618 297 | } 298 | } 299 | } 300 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/20200818221511_NewPropsToStats.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace Mog.Api.Infrastructure.Migrations 4 | { 5 | public partial class NewPropsToStats : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.AddColumn( 10 | name: "Class", 11 | table: "Stats", 12 | nullable: true); 13 | 14 | migrationBuilder.AddColumn( 15 | name: "Level", 16 | table: "Stats", 17 | nullable: false, 18 | defaultValue: 0); 19 | } 20 | 21 | protected override void Down(MigrationBuilder migrationBuilder) 22 | { 23 | migrationBuilder.DropColumn( 24 | name: "Class", 25 | table: "Stats"); 26 | 27 | migrationBuilder.DropColumn( 28 | name: "Level", 29 | table: "Stats"); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/20200922211456_NewFeedModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace Mog.Api.Infrastructure.Migrations 5 | { 6 | public partial class NewFeedModel : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.CreateTable( 11 | name: "Feed", 12 | columns: table => new 13 | { 14 | Id = table.Column(nullable: false), 15 | CharacterName = table.Column(nullable: true), 16 | Update = table.Column(nullable: false), 17 | Addition = table.Column(nullable: false), 18 | Deletion = table.Column(nullable: false), 19 | StatUpdate = table.Column(nullable: false), 20 | StatAddition = table.Column(nullable: false), 21 | StateDeletion = table.Column(nullable: false), 22 | Like = table.Column(nullable: false), 23 | UserName = table.Column(nullable: true), 24 | UserPhoto = table.Column(nullable: true), 25 | TimeStamp = table.Column(nullable: false) 26 | }, 27 | constraints: table => 28 | { 29 | table.PrimaryKey("PK_Feed", x => x.Id); 30 | }); 31 | } 32 | 33 | protected override void Down(MigrationBuilder migrationBuilder) 34 | { 35 | migrationBuilder.DropTable( 36 | name: "Feed"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/20201002115407_UpdateFeedModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace Mog.Api.Infrastructure.Migrations 4 | { 5 | public partial class UpdateFeedModel : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.AddColumn( 10 | name: "PhotoUpdate", 11 | table: "Feed", 12 | nullable: false, 13 | defaultValue: 0); 14 | } 15 | 16 | protected override void Down(MigrationBuilder migrationBuilder) 17 | { 18 | migrationBuilder.DropColumn( 19 | name: "PhotoUpdate", 20 | table: "Feed"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/20201003001943_UpdateFeedModelAgain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace Mog.Api.Infrastructure.Migrations 5 | { 6 | public partial class UpdateFeedModelAgain : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.DropColumn( 11 | name: "StateDeletion", 12 | table: "Feed"); 13 | 14 | migrationBuilder.AddColumn( 15 | name: "CharacterId", 16 | table: "Feed", 17 | nullable: false, 18 | defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); 19 | 20 | migrationBuilder.AddColumn( 21 | name: "StatDeletion", 22 | table: "Feed", 23 | nullable: false, 24 | defaultValue: 0); 25 | 26 | migrationBuilder.AddColumn( 27 | name: "UserFirstName", 28 | table: "Feed", 29 | nullable: true); 30 | } 31 | 32 | protected override void Down(MigrationBuilder migrationBuilder) 33 | { 34 | migrationBuilder.DropColumn( 35 | name: "CharacterId", 36 | table: "Feed"); 37 | 38 | migrationBuilder.DropColumn( 39 | name: "StatDeletion", 40 | table: "Feed"); 41 | 42 | migrationBuilder.DropColumn( 43 | name: "UserFirstName", 44 | table: "Feed"); 45 | 46 | migrationBuilder.AddColumn( 47 | name: "StateDeletion", 48 | table: "Feed", 49 | type: "int", 50 | nullable: false, 51 | defaultValue: 0); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/20201003173204_UpdateFeedReactions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace Mog.Api.Infrastructure.Migrations 4 | { 5 | public partial class UpdateFeedReactions : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.AddColumn( 10 | name: "Dislike", 11 | table: "Feed", 12 | nullable: false, 13 | defaultValue: 0); 14 | 15 | migrationBuilder.AddColumn( 16 | name: "Love", 17 | table: "Feed", 18 | nullable: false, 19 | defaultValue: 0); 20 | } 21 | 22 | protected override void Down(MigrationBuilder migrationBuilder) 23 | { 24 | migrationBuilder.DropColumn( 25 | name: "Dislike", 26 | table: "Feed"); 27 | 28 | migrationBuilder.DropColumn( 29 | name: "Love", 30 | table: "Feed"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/AsheDb/20210923040803_AddedBlogs.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using Mog.Api.Infrastructure; 9 | 10 | namespace Mog.Api.Infrastructure.Migrations.AsheDb 11 | { 12 | [DbContext(typeof(AsheDbContext))] 13 | [Migration("20210923040803_AddedBlogs")] 14 | partial class AddedBlogs 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 21 | .HasAnnotation("ProductVersion", "5.0.10") 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("Mog.Api.Core.Models.Blog", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("uniqueidentifier"); 29 | 30 | b.Property("Content") 31 | .IsRequired() 32 | .HasColumnType("nvarchar(max)"); 33 | 34 | b.Property("Created") 35 | .HasColumnType("datetimeoffset"); 36 | 37 | b.Property("Dislike") 38 | .HasColumnType("int"); 39 | 40 | b.Property("Like") 41 | .HasColumnType("int"); 42 | 43 | b.Property("Love") 44 | .HasColumnType("int"); 45 | 46 | b.HasKey("Id"); 47 | 48 | b.ToTable("Blogs"); 49 | }); 50 | #pragma warning restore 612, 618 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/AsheDb/20210923040803_AddedBlogs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace Mog.Api.Infrastructure.Migrations.AsheDb 5 | { 6 | public partial class AddedBlogs : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.CreateTable( 11 | name: "Blogs", 12 | columns: table => new 13 | { 14 | Id = table.Column(type: "uniqueidentifier", nullable: false), 15 | Content = table.Column(type: "nvarchar(max)", nullable: false), 16 | Like = table.Column(type: "int", nullable: false), 17 | Dislike = table.Column(type: "int", nullable: false), 18 | Love = table.Column(type: "int", nullable: false), 19 | Created = table.Column(type: "datetimeoffset", nullable: false) 20 | }, 21 | constraints: table => 22 | { 23 | table.PrimaryKey("PK_Blogs", x => x.Id); 24 | }); 25 | } 26 | 27 | protected override void Down(MigrationBuilder migrationBuilder) 28 | { 29 | migrationBuilder.DropTable( 30 | name: "Blogs"); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/AsheDb/20210923164659_AddedTitlePropToBlog.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using Mog.Api.Infrastructure; 9 | 10 | namespace Mog.Api.Infrastructure.Migrations.AsheDb 11 | { 12 | [DbContext(typeof(AsheDbContext))] 13 | [Migration("20210923164659_AddedTitlePropToBlog")] 14 | partial class AddedTitlePropToBlog 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 21 | .HasAnnotation("ProductVersion", "5.0.10") 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("Mog.Api.Core.Models.Blog", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("uniqueidentifier"); 29 | 30 | b.Property("Content") 31 | .IsRequired() 32 | .HasColumnType("nvarchar(max)"); 33 | 34 | b.Property("Created") 35 | .HasColumnType("datetimeoffset"); 36 | 37 | b.Property("Dislike") 38 | .HasColumnType("int"); 39 | 40 | b.Property("Like") 41 | .HasColumnType("int"); 42 | 43 | b.Property("Love") 44 | .HasColumnType("int"); 45 | 46 | b.Property("Title") 47 | .IsRequired() 48 | .HasMaxLength(50) 49 | .HasColumnType("nvarchar(50)"); 50 | 51 | b.HasKey("Id"); 52 | 53 | b.ToTable("Blogs"); 54 | }); 55 | #pragma warning restore 612, 618 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/AsheDb/20210923164659_AddedTitlePropToBlog.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore.Migrations; 2 | 3 | namespace Mog.Api.Infrastructure.Migrations.AsheDb 4 | { 5 | public partial class AddedTitlePropToBlog : Migration 6 | { 7 | protected override void Up(MigrationBuilder migrationBuilder) 8 | { 9 | migrationBuilder.AddColumn( 10 | name: "Title", 11 | table: "Blogs", 12 | type: "nvarchar(50)", 13 | maxLength: 50, 14 | nullable: false, 15 | defaultValue: ""); 16 | } 17 | 18 | protected override void Down(MigrationBuilder migrationBuilder) 19 | { 20 | migrationBuilder.DropColumn( 21 | name: "Title", 22 | table: "Blogs"); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/AsheDb/20210924124022_AddedUpdatedPropToBlog.Designer.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Migrations; 7 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 8 | using Mog.Api.Infrastructure; 9 | 10 | namespace Mog.Api.Infrastructure.Migrations.AsheDb 11 | { 12 | [DbContext(typeof(AsheDbContext))] 13 | [Migration("20210924124022_AddedUpdatedPropToBlog")] 14 | partial class AddedUpdatedPropToBlog 15 | { 16 | protected override void BuildTargetModel(ModelBuilder modelBuilder) 17 | { 18 | #pragma warning disable 612, 618 19 | modelBuilder 20 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 21 | .HasAnnotation("ProductVersion", "5.0.10") 22 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 23 | 24 | modelBuilder.Entity("Mog.Api.Core.Models.Blog", b => 25 | { 26 | b.Property("Id") 27 | .ValueGeneratedOnAdd() 28 | .HasColumnType("uniqueidentifier"); 29 | 30 | b.Property("Content") 31 | .IsRequired() 32 | .HasColumnType("nvarchar(max)"); 33 | 34 | b.Property("Created") 35 | .HasColumnType("datetimeoffset"); 36 | 37 | b.Property("Dislike") 38 | .HasColumnType("int"); 39 | 40 | b.Property("Like") 41 | .HasColumnType("int"); 42 | 43 | b.Property("Love") 44 | .HasColumnType("int"); 45 | 46 | b.Property("Title") 47 | .IsRequired() 48 | .HasMaxLength(50) 49 | .HasColumnType("nvarchar(50)"); 50 | 51 | b.Property("Updated") 52 | .HasColumnType("datetimeoffset"); 53 | 54 | b.HasKey("Id"); 55 | 56 | b.ToTable("Blogs"); 57 | }); 58 | #pragma warning restore 612, 618 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/AsheDb/20210924124022_AddedUpdatedPropToBlog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Microsoft.EntityFrameworkCore.Migrations; 3 | 4 | namespace Mog.Api.Infrastructure.Migrations.AsheDb 5 | { 6 | public partial class AddedUpdatedPropToBlog : Migration 7 | { 8 | protected override void Up(MigrationBuilder migrationBuilder) 9 | { 10 | migrationBuilder.AddColumn( 11 | name: "Updated", 12 | table: "Blogs", 13 | type: "datetimeoffset", 14 | nullable: false, 15 | defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0))); 16 | } 17 | 18 | protected override void Down(MigrationBuilder migrationBuilder) 19 | { 20 | migrationBuilder.DropColumn( 21 | name: "Updated", 22 | table: "Blogs"); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Migrations/AsheDb/AsheDbContextModelSnapshot.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System; 3 | using Microsoft.EntityFrameworkCore; 4 | using Microsoft.EntityFrameworkCore.Infrastructure; 5 | using Microsoft.EntityFrameworkCore.Metadata; 6 | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; 7 | using Mog.Api.Infrastructure; 8 | 9 | namespace Mog.Api.Infrastructure.Migrations.AsheDb 10 | { 11 | [DbContext(typeof(AsheDbContext))] 12 | partial class AsheDbContextModelSnapshot : ModelSnapshot 13 | { 14 | protected override void BuildModel(ModelBuilder modelBuilder) 15 | { 16 | #pragma warning disable 612, 618 17 | modelBuilder 18 | .HasAnnotation("Relational:MaxIdentifierLength", 128) 19 | .HasAnnotation("ProductVersion", "5.0.10") 20 | .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); 21 | 22 | modelBuilder.Entity("Mog.Api.Core.Models.Blog", b => 23 | { 24 | b.Property("Id") 25 | .ValueGeneratedOnAdd() 26 | .HasColumnType("uniqueidentifier"); 27 | 28 | b.Property("Content") 29 | .IsRequired() 30 | .HasColumnType("nvarchar(max)"); 31 | 32 | b.Property("Created") 33 | .HasColumnType("datetimeoffset"); 34 | 35 | b.Property("Dislike") 36 | .HasColumnType("int"); 37 | 38 | b.Property("Like") 39 | .HasColumnType("int"); 40 | 41 | b.Property("Love") 42 | .HasColumnType("int"); 43 | 44 | b.Property("Title") 45 | .IsRequired() 46 | .HasMaxLength(50) 47 | .HasColumnType("nvarchar(50)"); 48 | 49 | b.Property("Updated") 50 | .HasColumnType("datetimeoffset"); 51 | 52 | b.HasKey("Id"); 53 | 54 | b.ToTable("Blogs"); 55 | }); 56 | #pragma warning restore 612, 618 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/Mog.Api.Infrastructure.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | Mog.Api.Infrastructure 6 | 1591;1998 7 | 8 | 9 | 10 | 11 | 12 | 13 | runtime; build; native; contentfiles; analyzers; buildtransitive 14 | all 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Mog.Api.Infrastructure/SerahDbContext.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | 3 | namespace Mog.Api.Infrastructure 4 | { 5 | public class SerahDbContext : DbContext 6 | { 7 | public SerahDbContext(DbContextOptions options) 8 | : base(options) 9 | { } 10 | public DbSet Characters { get; set; } 11 | public DbSet Monsters { get; set; } 12 | public DbSet Games { get; set; } 13 | public DbSet Pictures { get; set; } 14 | public DbSet Stats { get; set; } 15 | public DbSet DatingProfile { get; set; } 16 | public DbSet Responses { get; set; } 17 | public DbSet Feed { get; set; } 18 | 19 | protected override void OnModelCreating(ModelBuilder builder) 20 | { 21 | base.OnModelCreating(builder); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Mog.Api/Controllers/API/V1/BlogController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using System.Collections.Generic; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.AspNetCore.Authorization; 8 | using Mog.Api.Core.Models; 9 | using Mog.Api.Core.WebApi; 10 | using Mog.Api.Core.Abstractions; 11 | using Mog.Api.Core.Extensions; 12 | 13 | namespace Mog.Api.Controllers.API.V1 14 | { 15 | [ApiVersion("1")] 16 | [Obsolete] 17 | public class BlogController : ApiControllerBase 18 | { 19 | private readonly IFactory, Guid> _blogFactory; 20 | private readonly IStore _blogStore; 21 | private readonly IStore> _blogReactionStore; 22 | 23 | public BlogController( 24 | IFactory, Guid> blogFactory, 25 | IStore blogStore, 26 | IStore> blogReactionStore) 27 | { 28 | _blogFactory = blogFactory; 29 | _blogStore = blogStore; 30 | _blogReactionStore = blogReactionStore; 31 | } 32 | 33 | [HttpGet] 34 | public async Task GetAll(Guid id, CancellationToken cancellationToken = new CancellationToken()) 35 | { 36 | try 37 | { 38 | var blogs = await _blogFactory.GetAsync(id, cancellationToken); 39 | if (blogs.Any()) 40 | { 41 | return Ok(blogs); 42 | } 43 | else 44 | { 45 | return Ok(new 46 | { 47 | message = "There are no blogs in the database." 48 | }); 49 | } 50 | } 51 | catch 52 | { 53 | return BadRequest(); 54 | } 55 | } 56 | 57 | [HttpGet("{id}")] 58 | public async Task Get(Guid id, CancellationToken cancellationToken = new CancellationToken()) 59 | { 60 | try 61 | { 62 | var blog = await _blogFactory.GetByKeyAsync(id, cancellationToken); 63 | if (blog.Any()) 64 | { 65 | return Ok(blog); 66 | } 67 | else 68 | { 69 | return Ok(new 70 | { 71 | message = "Couldn't find a blog with that id." 72 | }); 73 | } 74 | } 75 | catch 76 | { 77 | return BadRequest(); 78 | } 79 | } 80 | 81 | [Authorize(Roles = "Admin")] 82 | [HttpPost("add")] 83 | public async Task Add([FromForm] Blog model, CancellationToken cancellationToken = new CancellationToken()) 84 | { 85 | try 86 | { 87 | var blog = await _blogStore.AddAsync(model, cancellationToken); 88 | return Ok(new 89 | { 90 | message = "Blog record added successfully.", 91 | blog = blog 92 | }); 93 | } 94 | catch 95 | { 96 | return BadRequest(); 97 | } 98 | } 99 | 100 | [Authorize(Roles = "Admin")] 101 | [HttpPut("update/{id}")] 102 | public async Task Update(Guid id, [FromForm] Blog model, CancellationToken cancellationToken = new CancellationToken()) 103 | { 104 | var blog = await _blogFactory.GetByKeyAsync(id, cancellationToken); 105 | bool verify = false; 106 | 107 | if (blog.FirstOrDefault().Id == model.Id) 108 | { 109 | verify = true; 110 | } 111 | 112 | if (verify) 113 | { 114 | await _blogStore.UpdateAsync(model, cancellationToken); 115 | return Ok(new 116 | { 117 | message = "Blog updated successfully.", 118 | verified = verify, 119 | blog = model 120 | }); 121 | } 122 | else 123 | { 124 | return BadRequest(); 125 | } 126 | } 127 | 128 | [HttpPut("like/{id}")] 129 | public async Task Like(Guid id, CancellationToken cancellationToken = new CancellationToken()) 130 | { 131 | KeyValuePair reaction = new KeyValuePair(id, "like"); 132 | try 133 | { 134 | await _blogReactionStore.UpdateAsync(reaction, cancellationToken); 135 | return Ok(); 136 | } 137 | catch 138 | { 139 | return BadRequest(); 140 | } 141 | } 142 | 143 | [HttpPut("dislike/{id}")] 144 | public async Task Dislike(Guid id, CancellationToken cancellationToken = new CancellationToken()) 145 | { 146 | KeyValuePair reaction = new KeyValuePair(id, "dislike"); 147 | try 148 | { 149 | await _blogReactionStore.UpdateAsync(reaction, cancellationToken); 150 | return Ok(); 151 | } 152 | catch 153 | { 154 | return BadRequest(); 155 | } 156 | } 157 | 158 | [HttpPut("love/{id}")] 159 | public async Task Love(Guid id, CancellationToken cancellationToken = new CancellationToken()) 160 | { 161 | KeyValuePair reaction = new KeyValuePair(id, "love"); 162 | try 163 | { 164 | await _blogReactionStore.UpdateAsync(reaction, cancellationToken); 165 | return Ok(); 166 | } 167 | catch 168 | { 169 | return BadRequest(); 170 | } 171 | } 172 | 173 | [Authorize(Roles = "Admin")] 174 | [HttpDelete("delete/{id}")] 175 | public async Task Delete(Guid id, CancellationToken cancellationToken = new CancellationToken()) 176 | { 177 | try 178 | { 179 | var model = await _blogFactory.GetByKeyAsync(id, cancellationToken); 180 | await _blogStore.DeleteAsync(model.FirstOrDefault(), cancellationToken); 181 | return Ok(new 182 | { 183 | message = "Blog records removed successfully." 184 | }); 185 | } 186 | catch 187 | { 188 | return BadRequest(); 189 | } 190 | } 191 | } 192 | } -------------------------------------------------------------------------------- /Mog.Api/Controllers/API/V1/CharacterController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Mog.Api.Core.Models; 8 | using Mog.Api.Core.WebApi; 9 | using Mog.Api.Core.Abstractions; 10 | using Mog.Api.Core.Extensions; 11 | 12 | namespace Mog.Api.Controllers.API.V1 13 | { 14 | [ApiVersion("1")] 15 | public class CharacterController : ApiControllerBase 16 | { 17 | private readonly IFactory, Guid> _characterFactory; 18 | private readonly IStore _characterStore; 19 | 20 | public CharacterController( 21 | IFactory, Guid> characterFactory, 22 | IStore characterStore) 23 | { 24 | _characterFactory = characterFactory; 25 | _characterStore = characterStore; 26 | } 27 | 28 | [HttpGet] 29 | public async Task GetAll(Guid id, CancellationToken cancellationToken = new CancellationToken()) 30 | { 31 | try 32 | { 33 | var characters = await _characterFactory.GetAsync(id, cancellationToken); 34 | if (characters.Any()) 35 | { 36 | return Ok(characters); 37 | } 38 | else 39 | { 40 | return Ok(new 41 | { 42 | message = "There are no characters in the database." 43 | }); 44 | } 45 | } 46 | catch 47 | { 48 | return BadRequest(); 49 | } 50 | } 51 | 52 | [HttpGet("count")] 53 | public async Task GetCount(Guid id, CancellationToken cancellationToken = new CancellationToken()) 54 | { 55 | try 56 | { 57 | var characters = await _characterFactory.GetAsync(id, cancellationToken); 58 | if (characters.Any()) 59 | { 60 | return Ok(characters.Count()); 61 | } 62 | else 63 | { 64 | return Ok(0); 65 | } 66 | } 67 | catch 68 | { 69 | return BadRequest(); 70 | } 71 | } 72 | 73 | [HttpGet("{id}")] 74 | public async Task Get(Guid id, CancellationToken cancellationToken = new CancellationToken()) 75 | { 76 | try 77 | { 78 | var character = await _characterFactory.GetByKeyAsync(id, cancellationToken); 79 | if (character.Any()) 80 | { 81 | return Ok(character); 82 | } 83 | else 84 | { 85 | return Ok(new 86 | { 87 | message = "Couldn't find a character with that id." 88 | }); 89 | } 90 | } 91 | catch 92 | { 93 | return BadRequest(); 94 | } 95 | } 96 | 97 | [HttpGet("random")] 98 | public async Task Random(Guid id, CancellationToken cancellationToken = new CancellationToken()) 99 | { 100 | try 101 | { 102 | var characters = await _characterFactory.GetAsync(id, cancellationToken); 103 | var character = (from c in characters orderby Guid.NewGuid() select c).First(); 104 | return Ok(character); 105 | } 106 | catch 107 | { 108 | return BadRequest(); 109 | } 110 | } 111 | 112 | [HttpGet("search")] 113 | public async Task Search([FromQuery]string name, string gender, string job, string race, string origin, CancellationToken cancellationToken = new CancellationToken()) 114 | { 115 | Guid id = Guid.NewGuid(); 116 | 117 | try 118 | { 119 | var characters = await _characterFactory.GetAsync(id, cancellationToken); 120 | 121 | if (name != null) { 122 | characters = characters.OrderBy(c => c.Name).Where(c => c.Name.Contains(name)); 123 | } 124 | if (gender != null) { 125 | characters = characters.OrderBy(c => c.Name).Where(c => c.Gender == gender); 126 | } 127 | if (job != null) { 128 | characters = characters.OrderBy(c => c.Name).Where(c => c.Job.Contains(job)); 129 | } 130 | if (race != null) { 131 | characters = characters.OrderBy(c => c.Name).Where(c => c.Race.Contains(race)); 132 | } 133 | if (origin != null) { 134 | origin = ApplicationExtensions.ModifyOriginForSearch(origin); 135 | characters = characters.OrderBy(c => c.Name).Where(c => c.Origin == origin); 136 | } 137 | 138 | if (characters.Any()) 139 | { 140 | return Ok(characters); 141 | } 142 | else 143 | { 144 | return Ok(new 145 | { 146 | message = "Couldn't find that character." 147 | }); 148 | } 149 | } 150 | catch 151 | { 152 | return BadRequest(); 153 | } 154 | } 155 | 156 | [Authorize(Roles = "Admin")] 157 | [Obsolete] 158 | [HttpPost("add")] 159 | public async Task Add([FromForm] Character model, CancellationToken cancellationToken = new CancellationToken()) 160 | { 161 | try 162 | { 163 | var character = await _characterStore.AddAsync(model, cancellationToken); 164 | return Ok(new 165 | { 166 | message = "Character record added successfully.", 167 | character = character 168 | }); 169 | } 170 | catch 171 | { 172 | return BadRequest(); 173 | } 174 | } 175 | 176 | [Authorize(Roles = "Admin")] 177 | [Obsolete] 178 | [HttpPut("update/{id}")] 179 | public async Task Update(Guid id, [FromForm] Character model, CancellationToken cancellationToken = new CancellationToken()) 180 | { 181 | var character = await _characterFactory.GetByKeyAsync(id, cancellationToken); 182 | bool verify = false; 183 | 184 | if (character.FirstOrDefault().Id == model.Id) 185 | { 186 | verify = true; 187 | } 188 | 189 | if (verify) 190 | { 191 | await _characterStore.UpdateAsync(model, cancellationToken); 192 | return Ok(new 193 | { 194 | message = "Character updated successfully.", 195 | verified = verify, 196 | character = model 197 | }); 198 | } 199 | else 200 | { 201 | return BadRequest(); 202 | } 203 | } 204 | 205 | [Authorize(Roles = "Admin")] 206 | [Obsolete] 207 | [HttpDelete("delete/{id}")] 208 | public async Task Delete(Guid id, CancellationToken cancellationToken = new CancellationToken()) 209 | { 210 | try 211 | { 212 | var model = await _characterFactory.GetByKeyAsync(id, cancellationToken); 213 | await _characterStore.DeleteAsync(model.FirstOrDefault(), cancellationToken); 214 | return Ok(new 215 | { 216 | message = "Character records removed successfully." 217 | }); 218 | } 219 | catch 220 | { 221 | return BadRequest(); 222 | } 223 | } 224 | } 225 | } -------------------------------------------------------------------------------- /Mog.Api/Controllers/API/V1/DatingProfileController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Mog.Api.Core.Models; 8 | using Mog.Api.Core.WebApi; 9 | using Mog.Api.Core.Abstractions; 10 | 11 | namespace Mog.Api.Controllers.API.V1 12 | { 13 | [ApiVersion("1")] 14 | [Authorize(Roles = "Admin")] 15 | [Obsolete] 16 | public class DatingProfileController : ApiControllerBase 17 | { 18 | private readonly IFactory, Guid> _datingProfileFactory; 19 | 20 | public DatingProfileController( 21 | IFactory, Guid> datingProfileFactory) 22 | { 23 | _datingProfileFactory = datingProfileFactory; 24 | } 25 | 26 | [HttpGet] 27 | public async Task GetAll(Guid id, CancellationToken cancellationToken = new CancellationToken()) 28 | { 29 | try 30 | { 31 | var datingProfiles = await _datingProfileFactory.GetAsync(id, cancellationToken); 32 | if (datingProfiles.Any()) 33 | { 34 | return Ok(datingProfiles); 35 | } 36 | else 37 | { 38 | return Ok(new 39 | { 40 | message = "There are no profiles yet." 41 | }); 42 | } 43 | } 44 | catch 45 | { 46 | return BadRequest(); 47 | } 48 | } 49 | 50 | [HttpGet("{id}")] 51 | public async Task Get(Guid id, CancellationToken cancellationToken = new CancellationToken()) 52 | { 53 | try 54 | { 55 | var datingProfile = await _datingProfileFactory.GetByKeyAsync(id, cancellationToken); 56 | if (datingProfile.Any()) 57 | { 58 | return Ok(datingProfile); 59 | } 60 | else 61 | { 62 | return Ok(new 63 | { 64 | message = "There is no profile associated with this id." 65 | }); 66 | } 67 | } 68 | catch 69 | { 70 | return BadRequest(); 71 | } 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Mog.Api/Controllers/API/V1/FeedController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Mog.Api.Core.Models; 7 | using Mog.Api.Core.WebApi; 8 | using Mog.Api.Core.Abstractions; 9 | 10 | namespace Mog.Api.Controllers.API.V1 11 | { 12 | [ApiVersion("1")] 13 | public class FeedController : ApiControllerBase 14 | { 15 | private readonly IFactory, Guid> _feedFactory; 16 | private readonly IStore _feedStore; 17 | 18 | public FeedController( 19 | IFactory, Guid> feedFactory, 20 | IStore feedStore) 21 | { 22 | _feedFactory = feedFactory; 23 | _feedStore = feedStore; 24 | } 25 | 26 | [Obsolete] 27 | [HttpGet] 28 | public async Task Get(Guid id, CancellationToken cancellationToken = new CancellationToken()) 29 | { 30 | try 31 | { 32 | var feed = await _feedFactory.GetAsync(id, cancellationToken); 33 | if (feed.Any()) 34 | { 35 | return Ok(feed); 36 | } 37 | else 38 | { 39 | return Ok(new 40 | { 41 | message = "There is no data in the feed." 42 | }); 43 | } 44 | } 45 | catch 46 | { 47 | return BadRequest(); 48 | } 49 | } 50 | 51 | [Obsolete] 52 | [HttpPut("like/{id}")] 53 | public async Task Like(Guid id, CancellationToken cancellationToken = new CancellationToken()) 54 | { 55 | object[] reaction = {id, "like"}; 56 | try 57 | { 58 | await _feedStore.UpdateAsync(reaction, cancellationToken); 59 | return Ok(); 60 | } 61 | catch 62 | { 63 | return BadRequest(); 64 | } 65 | } 66 | 67 | [Obsolete] 68 | [HttpPut("dislike/{id}")] 69 | public async Task Dislike(Guid id, CancellationToken cancellationToken = new CancellationToken()) 70 | { 71 | object[] reaction = {id, "dislike"}; 72 | try 73 | { 74 | await _feedStore.UpdateAsync(reaction, cancellationToken); 75 | return Ok(); 76 | } 77 | catch 78 | { 79 | return BadRequest(); 80 | } 81 | } 82 | 83 | [Obsolete] 84 | [HttpPut("love/{id}")] 85 | public async Task Love(Guid id, CancellationToken cancellationToken = new CancellationToken()) 86 | { 87 | object[] reaction = {id, "love"}; 88 | try 89 | { 90 | await _feedStore.UpdateAsync(reaction, cancellationToken); 91 | return Ok(); 92 | } 93 | catch 94 | { 95 | return BadRequest(); 96 | } 97 | } 98 | } 99 | } -------------------------------------------------------------------------------- /Mog.Api/Controllers/API/V1/GameController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Mog.Api.Core.Models; 8 | using Mog.Api.Core.WebApi; 9 | using Mog.Api.Core.Abstractions; 10 | 11 | namespace Mog.Api.Controllers.API.V1 12 | { 13 | [ApiVersion("1")] 14 | public class GameController : ApiControllerBase 15 | { 16 | private readonly IFactory, Guid> _gameFactory; 17 | 18 | public GameController( 19 | IFactory, Guid> gameFactory) 20 | { 21 | _gameFactory = gameFactory; 22 | } 23 | 24 | [AllowAnonymous] 25 | [HttpGet] 26 | public async Task GetAll(Guid id, CancellationToken cancellationToken = new CancellationToken()) 27 | { 28 | try 29 | { 30 | var games = await _gameFactory.GetAsync(id, cancellationToken); 31 | return Ok(games); 32 | } 33 | catch 34 | { 35 | return BadRequest(); 36 | } 37 | } 38 | 39 | [AllowAnonymous] 40 | [HttpGet("{id}")] 41 | public async Task Get(Guid id, CancellationToken cancellationToken = new CancellationToken()) 42 | { 43 | try 44 | { 45 | var game = await _gameFactory.GetByKeyAsync(id, cancellationToken); 46 | return Ok(game); 47 | } 48 | catch 49 | { 50 | return NotFound(); 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /Mog.Api/Controllers/API/V1/MonsterController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Mog.Api.Core.Models; 8 | using Mog.Api.Core.WebApi; 9 | using Mog.Api.Core.Abstractions; 10 | 11 | namespace Mog.Api.Controllers.API.V1 12 | { 13 | [ApiVersion("1")] 14 | public class MonsterController : ApiControllerBase 15 | { 16 | private readonly IFactory, Guid> _monsterFactory; 17 | 18 | public MonsterController( 19 | IFactory, Guid> monsterFactory) 20 | { 21 | _monsterFactory = monsterFactory; 22 | } 23 | 24 | [AllowAnonymous] 25 | [HttpGet] 26 | public async Task GetAll(Guid id, CancellationToken cancellationToken = new CancellationToken()) 27 | { 28 | try 29 | { 30 | var monsters = await _monsterFactory.GetAsync(id, cancellationToken); 31 | return Ok(monsters); 32 | } 33 | catch 34 | { 35 | return BadRequest(); 36 | } 37 | } 38 | 39 | [AllowAnonymous] 40 | [HttpGet("{id}")] 41 | public async Task Get(Guid id, CancellationToken cancellationToken = new CancellationToken()) 42 | { 43 | try 44 | { 45 | var monster = await _monsterFactory.GetByKeyAsync(id, cancellationToken); 46 | return Ok(monster); 47 | } 48 | catch 49 | { 50 | return BadRequest(); 51 | } 52 | } 53 | 54 | [AllowAnonymous] 55 | [HttpGet("search")] 56 | public async Task Search([FromQuery]string name, CancellationToken cancellationToken = new CancellationToken()) 57 | { 58 | Guid id = Guid.NewGuid(); 59 | 60 | try 61 | { 62 | var monsters = await _monsterFactory.GetAsync(id, cancellationToken); 63 | if (name != null) { 64 | monsters = monsters.OrderBy(c => c.Name).Where(c => c.Name.Contains(name)); 65 | } 66 | 67 | return Ok(monsters); 68 | } 69 | catch 70 | { 71 | return BadRequest(); 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /Mog.Api/Controllers/API/V1/PictureController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Microsoft.AspNetCore.Mvc; 5 | using Microsoft.AspNetCore.Authorization; 6 | using Mog.Api.Core.Models; 7 | using Mog.Api.Core.WebApi; 8 | using Mog.Api.Core.Abstractions; 9 | 10 | namespace Mog.Api.Controllers.API.V1 11 | { 12 | [ApiVersion("1")] 13 | public class PictureController : ApiControllerBase 14 | { 15 | private readonly IStore _pictureStore; 16 | 17 | public PictureController( 18 | IStore pictureStore) 19 | { 20 | _pictureStore = pictureStore; 21 | } 22 | 23 | [Authorize(Roles = "Admin")] 24 | [Obsolete] 25 | [HttpPost("add")] 26 | public async Task Add([FromForm] Picture model, CancellationToken cancellationToken = new CancellationToken()) 27 | { 28 | try 29 | { 30 | await _pictureStore.AddAsync(model, cancellationToken); 31 | return Ok(new 32 | { 33 | message = "Picture added successfully." 34 | }); 35 | } 36 | catch 37 | { 38 | return BadRequest(new 39 | { 40 | message = "An error occurred processing the update." 41 | }); 42 | } 43 | } 44 | 45 | [Authorize(Roles = "Admin")] 46 | [Obsolete] 47 | [HttpPost("update")] 48 | public async Task Update([FromForm] Picture model, CancellationToken cancellationToken = new CancellationToken()) 49 | { 50 | try 51 | { 52 | await _pictureStore.UpdateAsync(model, cancellationToken); 53 | return Ok(new 54 | { 55 | message = "Picture updated successfully." 56 | }); 57 | } 58 | catch 59 | { 60 | return BadRequest(new 61 | { 62 | message = "An error occurred processing the update." 63 | }); 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /Mog.Api/Controllers/API/V1/StatController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.AspNetCore.Mvc; 6 | using Microsoft.AspNetCore.Authorization; 7 | using Mog.Api.Core.Models; 8 | using Mog.Api.Core.WebApi; 9 | using Mog.Api.Core.Abstractions; 10 | 11 | namespace Mog.Api.Controllers.API.V1 12 | { 13 | [ApiVersion("1")] 14 | public class StatController : ApiControllerBase 15 | { 16 | private readonly IFactory, Guid> _statFactory; 17 | private readonly IStore _statStore; 18 | 19 | public StatController( 20 | IFactory, Guid> statFactory, 21 | IStore statStore) 22 | { 23 | _statFactory = statFactory; 24 | _statStore = statStore; 25 | } 26 | 27 | [Authorize(Roles = "Admin")] 28 | [Obsolete] 29 | [HttpPost("add")] 30 | public async Task Add([FromForm] Stat model, CancellationToken cancellationToken = new CancellationToken()) 31 | { 32 | try 33 | { 34 | await _statStore.AddAsync(model, cancellationToken); 35 | return Ok(new 36 | { 37 | message = "Stat record added successfully." 38 | }); 39 | } 40 | catch 41 | { 42 | return BadRequest(); 43 | } 44 | } 45 | 46 | [Authorize(Roles = "Admin")] 47 | [Obsolete] 48 | [HttpPut("update/{id}")] 49 | public async Task Update(Guid id, [FromForm] Stat model, CancellationToken cancellationToken = new CancellationToken()) 50 | { 51 | var stat = await _statFactory.GetByKeyAsync(id, cancellationToken); 52 | bool verify = false; 53 | 54 | if (stat.FirstOrDefault().Id == model.Id) 55 | { 56 | verify = true; 57 | } 58 | 59 | if (verify) 60 | { 61 | await _statStore.UpdateAsync(model, cancellationToken); 62 | return Ok(new 63 | { 64 | message = "Stats updated successfully.", 65 | verified = verify, 66 | stat = model 67 | }); 68 | } 69 | else 70 | { 71 | return BadRequest(); 72 | } 73 | } 74 | 75 | [Authorize(Roles = "Admin")] 76 | [Obsolete] 77 | [HttpDelete("delete/{id}")] 78 | public async Task Delete(Guid id, CancellationToken cancellationToken = new CancellationToken()) 79 | { 80 | try 81 | { 82 | var model = await _statFactory.GetByKeyAsync(id, cancellationToken); 83 | await _statStore.DeleteAsync(model.FirstOrDefault(), cancellationToken); 84 | return Ok(new 85 | { 86 | message = "Stat record removed successfully." 87 | }); 88 | } 89 | catch 90 | { 91 | return BadRequest(); 92 | } 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /Mog.Api/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace Mog.Api.Controllers 4 | { 5 | [ApiExplorerSettings(IgnoreApi = true)] 6 | public class HomeController : Controller 7 | { 8 | public IActionResult Index() 9 | { 10 | return View(); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Mog.Api/Controllers/SwaggerController.cs: -------------------------------------------------------------------------------- 1 | 2 | using Microsoft.AspNetCore.Mvc; 3 | 4 | namespace Mog.Api.Controllers 5 | { 6 | [ApiExplorerSettings(IgnoreApi = true)] 7 | public class SwaggerController : ControllerBase 8 | { 9 | [HttpGet] 10 | //[Route("")] 11 | [Route("swagger")] 12 | [Route("index.html")] 13 | public RedirectResult DefaultRedirect() 14 | { 15 | return Redirect("~/swagger/index.html"); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /Mog.Api/Mog.Api.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | InProcess 6 | 1591;1998 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | all 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Mog.Api/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.Extensions.Logging; 4 | using Mog.Api.Core.Logging; 5 | using Mog.Api.Core.Extensions; 6 | 7 | namespace Mog.Api 8 | { 9 | public class Program 10 | { 11 | 12 | public static void Main(string[] args) 13 | { 14 | var builder = CreateWebHostBuilder(args) 15 | .Build() 16 | .RegisterDefaultJson(); 17 | 18 | builder.Run(); 19 | } 20 | 21 | public static IWebHostBuilder CreateWebHostBuilder(string[] args) => 22 | WebHost.CreateDefaultBuilder(args) 23 | .ConfigureLogging((context, logging) => 24 | { 25 | logging.AddConfiguration(context.Configuration.GetSection("Logging")); 26 | 27 | // Only add debugging and console while debugging the application 28 | if (DebugSettings.IsDebugging) 29 | { 30 | logging.AddDebug(); 31 | logging.AddConsole(); 32 | } 33 | }) 34 | .UseStartup(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Mog.Api/Startup.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Collections.Generic; 3 | using Microsoft.AspNetCore.Builder; 4 | using Microsoft.AspNetCore.Hosting; 5 | using Microsoft.Extensions.Configuration; 6 | using Microsoft.Extensions.DependencyInjection; 7 | using Microsoft.OpenApi.Models; 8 | using Microsoft.Extensions.Hosting; 9 | using Microsoft.EntityFrameworkCore; 10 | using Newtonsoft.Json.Serialization; 11 | using Newtonsoft.Json.Converters; 12 | using Mog.Api.Infrastructure; 13 | using Mog.Api.Core.Extensions; 14 | using Mog.Api.Core.Logging; 15 | using Mog.Api.Core.Security; 16 | using Mog.Api.Core.Swagger; 17 | 18 | namespace Mog.Api 19 | { 20 | public class Startup 21 | { 22 | public Startup(IConfiguration configuration, IWebHostEnvironment environment) 23 | { 24 | Configuration = configuration; 25 | Environment = environment; 26 | } 27 | 28 | public static IConfiguration Configuration { get; private set; } 29 | public static IWebHostEnvironment Environment { get; private set; } 30 | 31 | public void ConfigureServices(IServiceCollection services) 32 | { 33 | services.AddSingleton(Configuration); 34 | services.AddSingleton(Environment); 35 | services.AddMemoryCache(); 36 | services.Configure(Configuration.GetSection(nameof(SwaggerSettings))); 37 | services.Configure(Configuration.GetSection(nameof(ApplicationMetadata))); 38 | services.AddDbContext(x => x.UseSqlServer(Configuration.GetConnectionString("Serah"))); 39 | services.AddDbContext(x => x.UseSqlServer(Configuration.GetConnectionString("Ashe"))); 40 | services.AddHttpContextAccessor(); 41 | 42 | var jwtSection = Configuration.GetSection(nameof(AppSettings)); 43 | var assembly = Assembly.Load("Mog.Api.Infrastructure"); 44 | services.Configure(jwtSection); 45 | services.AddFactories(assembly) 46 | .AddStores(assembly); 47 | 48 | services.AddJwtAuthentication(jwtSection) 49 | .AddControllers() 50 | .AddNewtonsoftJson(x => { 51 | x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; 52 | x.SerializerSettings.ContractResolver = 53 | new DefaultContractResolver 54 | { 55 | NamingStrategy = new CamelCaseNamingStrategy() 56 | }; 57 | x.SerializerSettings.Converters.Add(new StringEnumConverter()); 58 | }); 59 | 60 | services.AddApiVersionWithExplorer() 61 | .AddSwaggerOptions() 62 | .AddSwaggerGen(x => 63 | { 64 | var security = new OpenApiSecurityRequirement() 65 | { 66 | { 67 | new OpenApiSecurityScheme 68 | { 69 | Reference = new OpenApiReference 70 | { 71 | Type = ReferenceType.SecurityScheme, 72 | Id = "Bearer" 73 | }, 74 | Scheme = "oauth2", 75 | Name = "Bearer", 76 | In = ParameterLocation.Header 77 | }, 78 | new List() 79 | } 80 | }; 81 | 82 | x.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme 83 | { 84 | Description = "JWT Authorization header", 85 | Name = "Authorization", 86 | In = ParameterLocation.Header, 87 | Type = SecuritySchemeType.ApiKey 88 | }); 89 | 90 | x.AddSecurityRequirement(security); 91 | }); // Generates Authorize button and makes swagger aware of authorization with JWT 92 | 93 | services.AddControllersWithViews(); 94 | services.AddRouting(x => x.LowercaseUrls = true); 95 | } 96 | 97 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 98 | { 99 | if (!env.IsDevelopment()) 100 | { 101 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 102 | app.UseHsts(); 103 | } 104 | 105 | app.UseSwaggerDocuments(); 106 | app.UseRouting(); 107 | app.UseCors(x => x 108 | .AllowAnyOrigin() 109 | .AllowAnyMethod() 110 | .AllowAnyHeader()); 111 | 112 | app.UseHttpsRedirection(); 113 | app.UseStaticFiles(); 114 | app.UseAuthentication(); 115 | app.UseAuthorization(); 116 | app.UseEndpoints(x => { 117 | x.MapControllerRoute( 118 | name: "default", 119 | pattern: "{controller=Home}/{action=Index}/{id?}"); 120 | x.MapControllers(); 121 | }); 122 | } 123 | } 124 | } -------------------------------------------------------------------------------- /Mog.Api/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 |  7 |
8 | 9 |
10 |
11 |

What is this?

12 |
13 |
14 |

This is a RESTful API for Final Fantasy. I hope the database behind will eventually become an extensive library of all your favorite characters and monsters from the main series of Final Fantasy.

15 |

There's currently characters and counting!

16 |
17 |
18 |

If you're interested in building something and not sure where to start you can checkout the README on GitHub. I've included some easy to follow examples. There's also a simple working demo here.

19 |

Or you can play with the SWAGGER for testing.

20 |
21 |
22 |
23 |
24 | 25 | 26 | 27 | 28 |
What is an API?
29 |

An API (Application Programming Interface) is a software-to-software interface, not a user interface. With APIs, applications talk to each other without any user knowledge or intervention. When you buy movie tickets online and enter your credit card information, the movie ticket website uses an API to send your credit card information to a remote application that verifies whether your information is correct. Once payment is confirmed, the remote application sends a response back to the movie ticket website saying it's okay to issue the tickets.

30 |
31 |
32 | 33 | 34 | 35 | 36 |
Aren't there a bunch of Final Fantasy websites?
37 |

Exactly. That means there's a bunch of different sources of the same/similar data.

38 |

The goal is to provide a single source of data that any website can consume and use. When new games come out it could take some time for a variety of websites to catch up. With the API it could be updated once and the new information can then be consumed by any number of websites at the same time.

39 |
40 |
41 | 42 | 43 | 44 | 45 |
Where did you get the data?
46 |

I've spent hours upon hours in most of the games over the majority of my life. I also have a decent collection of games and strategy guides. I'm also curious, a developer, reader, and know how to traverse internet fairly well. I'm doing my best to gather data from multiple sources and compile it in one place.

47 |
48 |
49 | 50 | 51 | 52 | 53 |
The API is missing stuff!
54 |

I know! I contribute and update when I have time but it's just me doing it! I'd love to find contributors; so if you're interested send me an email. You can also check here for updates to the data.

55 |
56 |
57 | 58 | 59 | 60 | 61 |
What is the tech stack?
62 |

The API is built in C#/.NETCore. It's hosted in Azure, with an Azure SQL database, and set behind Cloudflare for caching. My sample example is wired up with a Vue.js component and Selphie is built with React.js.

63 |
64 |
65 | 66 | 67 | 68 | 69 |
Can I help?
70 |

Absolutely! If you'd like to help contribute to the data send me an email. I'm super open to suggestions and collaboration!

71 |
72 |
73 |
-------------------------------------------------------------------------------- /Mog.Api/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 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 | @RenderSection("Styles", false) 42 | 43 | moogleAPI 44 | 45 | 46 |
47 | 58 | 59 |
60 |
61 | @RenderBody() 62 |
63 | 76 | 77 | @RenderSection("Scripts", required: false) 78 | 79 | 80 | -------------------------------------------------------------------------------- /Mog.Api/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 18 | 19 | -------------------------------------------------------------------------------- /Mog.Api/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Mog 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /Mog.Api/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } -------------------------------------------------------------------------------- /Mog.Api/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * MoogleApi custom CSS 3 | */ 4 | body { 5 | padding: 50px; 6 | font-family: "Raleway"; 7 | font-size: 14px; 8 | } 9 | .index { 10 | margin-top: 50px; 11 | } 12 | /*Fonts*/ 13 | @font-face { 14 | font-family: 'Josefin Sans'; 15 | src: url('../customfonts/JosefinSans-VariableFont_wght.ttf') format('opentype'); 16 | } 17 | @font-face { 18 | font-family: 'Raleway'; 19 | src: url('../customfonts/Raleway-VariableFont_wght.ttf') format('opentype'); 20 | } 21 | /*Site logo*/ 22 | .site-logo-container { 23 | height: 50px; 24 | min-width: 100%; 25 | width: 100%; 26 | position: fixed; 27 | top: 0; 28 | left: 0; 29 | padding: 0 20px; 30 | z-index: 1000; 31 | } 32 | .site-logo { 33 | letter-spacing: 10px; 34 | cursor: pointer; 35 | font-family: 'Josefin Sans',sans-serif; 36 | } 37 | .site-logo a { 38 | text-decoration: none; 39 | } 40 | .no-space { 41 | letter-spacing: -35px; 42 | } 43 | .custom-margin-left { 44 | margin-left: -12px; 45 | } 46 | .site-span-api { 47 | font-size: 12px; 48 | font-weight: bolder; 49 | letter-spacing: 0; 50 | } 51 | .site-span-api-sm { 52 | font-size: 6px; 53 | } 54 | .logo-img { 55 | width: 27px; 56 | margin-right: -35px; 57 | transform: rotate(-12deg); 58 | } 59 | /*_Information*/ 60 | .info-box-container { 61 | z-index: 500; 62 | } 63 | .info-box { 64 | min-height: 220px; 65 | border-radius: 5px; 66 | } 67 | .info-box p { 68 | padding: 0 20px; 69 | } 70 | .info-icon-row { 71 | margin: 30px auto; 72 | } 73 | .info-icon-row p { 74 | padding: 0 3px; 75 | } 76 | /*Footer*/ 77 | footer { 78 | padding: 30px 0; 79 | } 80 | footer a, 81 | footer a:visited { 82 | color: #37474F; 83 | text-decoration: none; 84 | transition: all .3s ease-in-out; 85 | } 86 | footer i { 87 | color: #37474F; 88 | padding-left: 10px; 89 | font-size: 20px; 90 | float: right; 91 | } 92 | footer span a i.fab:hover, 93 | footer span a i.fab:focus { 94 | color: #4285F4; 95 | transform: rotate(7deg); 96 | } 97 | /* footer span a i.fa-facebook-square:hover, 98 | footer span a i.fa-facebook-square:focus { 99 | color: #4285F4; 100 | transform: rotate(7deg); 101 | } 102 | footer span a i.fa-instagram:hover, 103 | footer span a i.ffa-instagram:focus { 104 | color: #CC0000; 105 | transform: rotate(7deg); 106 | } 107 | footer span a i.fa-github-square:hover, 108 | footer span a i.fa-github-square:focus { 109 | color: #ffbb33; 110 | transform: rotate(7deg); 111 | } 112 | footer span a i.fa-linkedin:hover, 113 | footer span a i.fa-linkedin:focus { 114 | color: #007E33; 115 | transform: rotate(7deg); 116 | } */ 117 | /*Search container*/ 118 | .search-card { 119 | margin: 0 auto; 120 | width: 80%; 121 | height: 50px; 122 | } 123 | .search-card-row { 124 | position: fixed; 125 | top: 0; 126 | left: 0; 127 | margin-bottom: 0; 128 | padding-top: 100px; 129 | padding-bottom: 0; 130 | z-index: 500; 131 | width: 34%; 132 | } 133 | .fancy-search { 134 | width: 100%; 135 | padding: 10px 0 10px 15px; 136 | border-radius: 500px; 137 | border: 1px solid transparent; 138 | transition: ease-in-out .1s; 139 | } 140 | ::placeholder { 141 | font-size: 14px; 142 | color:#455a64 ; 143 | } 144 | input:focus::-webkit-input-placeholder { color:transparent; } 145 | input:focus:-moz-placeholder { color:transparent; } /* FF 4-18 */ 146 | input:focus::-moz-placeholder { color:transparent; } /* FF 19+ */ 147 | input:focus:-ms-input-placeholder { color:transparent; } /* IE 10+ */ 148 | .search-results-container { 149 | height: 100vh; 150 | overflow: scroll; 151 | } 152 | .search-results-container::-webkit-scrollbar { 153 | width: 0px; 154 | background: transparent; 155 | } 156 | .search-results-img { 157 | width: 150px; 158 | } 159 | /*Dark mode*/ 160 | .dark-mode .bg-white { 161 | background-color: #25282c !important; 162 | } 163 | .dark-mode .bg-light { 164 | background-color: #37474F !important; 165 | } 166 | .dark-mode .text-light, 167 | .dark-mode .text-white { 168 | color: #37474F !important; 169 | } 170 | .dark-mode .text-dark, 171 | .dark-mode .text-muted { 172 | color: #fff !important; 173 | } 174 | .dark-mode .text-primary { 175 | color: #bbdefb !important; 176 | } 177 | .dark-mode .text-secondary { 178 | color: #ffecb3 !important; 179 | } 180 | .dark-mode .text-success { 181 | color: #c8e6c9 !important; 182 | } 183 | .dark-mode .text-danger { 184 | color: #ffcdd2 !important; 185 | } 186 | .restful { 187 | display: inline; 188 | } 189 | 190 | @media screen and (max-width: 767px) { 191 | .search-card-row { 192 | padding-top: 50px; 193 | width: 100%; 194 | } 195 | footer { 196 | width: 100%; 197 | margin-bottom: 30px; 198 | } 199 | footer > .copyright { 200 | display: none; 201 | } 202 | footer > a { 203 | display: none; 204 | } 205 | footer i { 206 | font-size: 34px; 207 | float: none; 208 | margin: 0 10px; 209 | } 210 | .restful { 211 | display: none; 212 | } 213 | } -------------------------------------------------------------------------------- /Mog.Api/wwwroot/customfonts/JosefinSans-Italic-VariableFont_wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/customfonts/JosefinSans-Italic-VariableFont_wght.ttf -------------------------------------------------------------------------------- /Mog.Api/wwwroot/customfonts/JosefinSans-VariableFont_wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/customfonts/JosefinSans-VariableFont_wght.ttf -------------------------------------------------------------------------------- /Mog.Api/wwwroot/customfonts/Raleway-Italic-VariableFont_wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/customfonts/Raleway-Italic-VariableFont_wght.ttf -------------------------------------------------------------------------------- /Mog.Api/wwwroot/customfonts/Raleway-VariableFont_wght.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/customfonts/Raleway-VariableFont_wght.ttf -------------------------------------------------------------------------------- /Mog.Api/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Mog.Api/wwwroot/icons/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/icons/apple-touch-icon.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/icons/moogleapi-icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/icons/moogleapi-icon-192.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/icons/moogleapi-icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/icons/moogleapi-icon-512.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/icons/penelo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/icons/penelo.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/icons/selphie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/icons/selphie.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/images/moogle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/images/moogle.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/images/no-image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/images/no-image.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/js/moogleapi-main.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | if (halfmoon.readCookie("darkModeOn") == "yes") { 3 | halfmoon.toggleDarkMode(); 4 | } 5 | 6 | getCount(); 7 | setInterval(getCount, 300000); 8 | }); 9 | 10 | function getCount() { 11 | $("#character-count").html(''); 12 | fetch("https://www.moogleapi.com/api/v1/characters/count") 13 | .then(function(response) { 14 | return response.json(); 15 | }).then(function(data) { 16 | console.log("Character count: " + data); 17 | $("#character-count").text(data); 18 | }); 19 | } -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/bootstrap/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bootstrap", 3 | "description": "The most popular front-end framework for developing responsive, mobile first projects on the web.", 4 | "keywords": [ 5 | "css", 6 | "js", 7 | "less", 8 | "mobile-first", 9 | "responsive", 10 | "front-end", 11 | "framework", 12 | "web" 13 | ], 14 | "homepage": "http://getbootstrap.com", 15 | "license": "MIT", 16 | "moduleType": "globals", 17 | "main": [ 18 | "less/bootstrap.less", 19 | "dist/js/bootstrap.js" 20 | ], 21 | "ignore": [ 22 | "/.*", 23 | "_config.yml", 24 | "CNAME", 25 | "composer.json", 26 | "CONTRIBUTING.md", 27 | "docs", 28 | "js/tests", 29 | "test-infra" 30 | ], 31 | "dependencies": { 32 | "jquery": "1.9.1 - 3" 33 | }, 34 | "version": "3.3.7", 35 | "_release": "3.3.7", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.3.7", 39 | "commit": "0b9c4a4007c44201dce9a6cc1a38407005c26c86" 40 | }, 41 | "_source": "https://github.com/twbs/bootstrap.git", 42 | "_target": "v3.3.7", 43 | "_originalSource": "bootstrap", 44 | "_direct": true 45 | } -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2016 Twitter, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.2.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2018 The Bootstrap Authors 4 | * Copyright 2011-2018 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */ 8 | *, 9 | *::before, 10 | *::after { 11 | box-sizing: border-box; 12 | } 13 | 14 | html { 15 | font-family: sans-serif; 16 | line-height: 1.15; 17 | -webkit-text-size-adjust: 100%; 18 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 19 | } 20 | 21 | article, aside, figcaption, figure, footer, header, hgroup, main, nav, section { 22 | display: block; 23 | } 24 | 25 | body { 26 | margin: 0; 27 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; 28 | font-size: 1rem; 29 | font-weight: 400; 30 | line-height: 1.5; 31 | color: #212529; 32 | text-align: left; 33 | background-color: #fff; 34 | } 35 | 36 | [tabindex="-1"]:focus { 37 | outline: 0 !important; 38 | } 39 | 40 | hr { 41 | box-sizing: content-box; 42 | height: 0; 43 | overflow: visible; 44 | } 45 | 46 | h1, h2, h3, h4, h5, h6 { 47 | margin-top: 0; 48 | margin-bottom: 0.5rem; 49 | } 50 | 51 | p { 52 | margin-top: 0; 53 | margin-bottom: 1rem; 54 | } 55 | 56 | abbr[title], 57 | abbr[data-original-title] { 58 | text-decoration: underline; 59 | -webkit-text-decoration: underline dotted; 60 | text-decoration: underline dotted; 61 | cursor: help; 62 | border-bottom: 0; 63 | text-decoration-skip-ink: none; 64 | } 65 | 66 | address { 67 | margin-bottom: 1rem; 68 | font-style: normal; 69 | line-height: inherit; 70 | } 71 | 72 | ol, 73 | ul, 74 | dl { 75 | margin-top: 0; 76 | margin-bottom: 1rem; 77 | } 78 | 79 | ol ol, 80 | ul ul, 81 | ol ul, 82 | ul ol { 83 | margin-bottom: 0; 84 | } 85 | 86 | dt { 87 | font-weight: 700; 88 | } 89 | 90 | dd { 91 | margin-bottom: .5rem; 92 | margin-left: 0; 93 | } 94 | 95 | blockquote { 96 | margin: 0 0 1rem; 97 | } 98 | 99 | b, 100 | strong { 101 | font-weight: bolder; 102 | } 103 | 104 | small { 105 | font-size: 80%; 106 | } 107 | 108 | sub, 109 | sup { 110 | position: relative; 111 | font-size: 75%; 112 | line-height: 0; 113 | vertical-align: baseline; 114 | } 115 | 116 | sub { 117 | bottom: -.25em; 118 | } 119 | 120 | sup { 121 | top: -.5em; 122 | } 123 | 124 | a { 125 | color: #007bff; 126 | text-decoration: none; 127 | background-color: transparent; 128 | } 129 | 130 | a:hover { 131 | color: #0056b3; 132 | text-decoration: underline; 133 | } 134 | 135 | a:not([href]):not([tabindex]) { 136 | color: inherit; 137 | text-decoration: none; 138 | } 139 | 140 | a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus { 141 | color: inherit; 142 | text-decoration: none; 143 | } 144 | 145 | a:not([href]):not([tabindex]):focus { 146 | outline: 0; 147 | } 148 | 149 | pre, 150 | code, 151 | kbd, 152 | samp { 153 | font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; 154 | font-size: 1em; 155 | } 156 | 157 | pre { 158 | margin-top: 0; 159 | margin-bottom: 1rem; 160 | overflow: auto; 161 | } 162 | 163 | figure { 164 | margin: 0 0 1rem; 165 | } 166 | 167 | img { 168 | vertical-align: middle; 169 | border-style: none; 170 | } 171 | 172 | svg { 173 | overflow: hidden; 174 | vertical-align: middle; 175 | } 176 | 177 | table { 178 | border-collapse: collapse; 179 | } 180 | 181 | caption { 182 | padding-top: 0.75rem; 183 | padding-bottom: 0.75rem; 184 | color: #6c757d; 185 | text-align: left; 186 | caption-side: bottom; 187 | } 188 | 189 | th { 190 | text-align: inherit; 191 | } 192 | 193 | label { 194 | display: inline-block; 195 | margin-bottom: 0.5rem; 196 | } 197 | 198 | button { 199 | border-radius: 0; 200 | } 201 | 202 | button:focus { 203 | outline: 1px dotted; 204 | outline: 5px auto -webkit-focus-ring-color; 205 | } 206 | 207 | input, 208 | button, 209 | select, 210 | optgroup, 211 | textarea { 212 | margin: 0; 213 | font-family: inherit; 214 | font-size: inherit; 215 | line-height: inherit; 216 | } 217 | 218 | button, 219 | input { 220 | overflow: visible; 221 | } 222 | 223 | button, 224 | select { 225 | text-transform: none; 226 | } 227 | 228 | button, 229 | [type="button"], 230 | [type="reset"], 231 | [type="submit"] { 232 | -webkit-appearance: button; 233 | } 234 | 235 | button::-moz-focus-inner, 236 | [type="button"]::-moz-focus-inner, 237 | [type="reset"]::-moz-focus-inner, 238 | [type="submit"]::-moz-focus-inner { 239 | padding: 0; 240 | border-style: none; 241 | } 242 | 243 | input[type="radio"], 244 | input[type="checkbox"] { 245 | box-sizing: border-box; 246 | padding: 0; 247 | } 248 | 249 | input[type="date"], 250 | input[type="time"], 251 | input[type="datetime-local"], 252 | input[type="month"] { 253 | -webkit-appearance: listbox; 254 | } 255 | 256 | textarea { 257 | overflow: auto; 258 | resize: vertical; 259 | } 260 | 261 | fieldset { 262 | min-width: 0; 263 | padding: 0; 264 | margin: 0; 265 | border: 0; 266 | } 267 | 268 | legend { 269 | display: block; 270 | width: 100%; 271 | max-width: 100%; 272 | padding: 0; 273 | margin-bottom: .5rem; 274 | font-size: 1.5rem; 275 | line-height: inherit; 276 | color: inherit; 277 | white-space: normal; 278 | } 279 | 280 | progress { 281 | vertical-align: baseline; 282 | } 283 | 284 | [type="number"]::-webkit-inner-spin-button, 285 | [type="number"]::-webkit-outer-spin-button { 286 | height: auto; 287 | } 288 | 289 | [type="search"] { 290 | outline-offset: -2px; 291 | -webkit-appearance: none; 292 | } 293 | 294 | [type="search"]::-webkit-search-decoration { 295 | -webkit-appearance: none; 296 | } 297 | 298 | ::-webkit-file-upload-button { 299 | font: inherit; 300 | -webkit-appearance: button; 301 | } 302 | 303 | output { 304 | display: inline-block; 305 | } 306 | 307 | summary { 308 | display: list-item; 309 | cursor: pointer; 310 | } 311 | 312 | template { 313 | display: none; 314 | } 315 | 316 | [hidden] { 317 | display: none !important; 318 | } 319 | /*# sourceMappingURL=bootstrap-reboot.css.map */ -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Reboot v4.2.1 (https://getbootstrap.com/) 3 | * Copyright 2011-2018 The Bootstrap Authors 4 | * Copyright 2011-2018 Twitter, Inc. 5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 6 | * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) 7 | */*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important} 8 | /*# sourceMappingURL=bootstrap-reboot.min.css.map */ -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/lib/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/jquery-validation-unobtrusive/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation-unobtrusive", 3 | "version": "3.2.6", 4 | "homepage": "https://github.com/aspnet/jquery-validation-unobtrusive", 5 | "description": "Add-on to jQuery Validation to enable unobtrusive validation options in data-* attributes.", 6 | "main": [ 7 | "jquery.validate.unobtrusive.js" 8 | ], 9 | "ignore": [ 10 | "**/.*", 11 | "*.json", 12 | "*.md", 13 | "*.txt", 14 | "gulpfile.js" 15 | ], 16 | "keywords": [ 17 | "jquery", 18 | "asp.net", 19 | "mvc", 20 | "validation", 21 | "unobtrusive" 22 | ], 23 | "authors": [ 24 | "Microsoft" 25 | ], 26 | "license": "http://www.microsoft.com/web/webpi/eula/net_library_eula_enu.htm", 27 | "repository": { 28 | "type": "git", 29 | "url": "git://github.com/aspnet/jquery-validation-unobtrusive.git" 30 | }, 31 | "dependencies": { 32 | "jquery-validation": ">=1.8", 33 | "jquery": ">=1.8" 34 | }, 35 | "_release": "3.2.6", 36 | "_resolution": { 37 | "type": "version", 38 | "tag": "v3.2.6", 39 | "commit": "13386cd1b5947d8a5d23a12b531ce3960be1eba7" 40 | }, 41 | "_source": "git://github.com/aspnet/jquery-validation-unobtrusive.git", 42 | "_target": "3.2.6", 43 | "_originalSource": "jquery-validation-unobtrusive" 44 | } -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | ** Unobtrusive validation support library for jQuery and jQuery Validate 3 | ** Copyright (C) Microsoft Corporation. All rights reserved. 4 | */ 5 | !function(a){function e(a,e,n){a.rules[e]=n,a.message&&(a.messages[e]=a.message)}function n(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function t(a){return a.replace(/([!"#$%&'()*+,./:;<=>?@\[\\\]^`{|}~])/g,"\\$1")}function r(a){return a.substr(0,a.lastIndexOf(".")+1)}function i(a,e){return 0===a.indexOf("*.")&&(a=a.replace("*.",e)),a}function o(e,n){var r=a(this).find("[data-valmsg-for='"+t(n[0].name)+"']"),i=r.attr("data-valmsg-replace"),o=i?a.parseJSON(i)!==!1:null;r.removeClass("field-validation-valid").addClass("field-validation-error"),e.data("unobtrusiveContainer",r),o?(r.empty(),e.removeClass("input-validation-error").appendTo(r)):e.hide()}function d(e,n){var t=a(this).find("[data-valmsg-summary=true]"),r=t.find("ul");r&&r.length&&n.errorList.length&&(r.empty(),t.addClass("validation-summary-errors").removeClass("validation-summary-valid"),a.each(n.errorList,function(){a("
  • ").html(this.message).appendTo(r)}))}function s(e){var n=e.data("unobtrusiveContainer");if(n){var t=n.attr("data-valmsg-replace"),r=t?a.parseJSON(t):null;n.addClass("field-validation-valid").removeClass("field-validation-error"),e.removeData("unobtrusiveContainer"),r&&n.empty()}}function l(e){var n=a(this),t="__jquery_unobtrusive_validation_form_reset";if(!n.data(t)){n.data(t,!0);try{n.data("validator").resetForm()}finally{n.removeData(t)}n.find(".validation-summary-errors").addClass("validation-summary-valid").removeClass("validation-summary-errors"),n.find(".field-validation-error").addClass("field-validation-valid").removeClass("field-validation-error").removeData("unobtrusiveContainer").find(">*").removeData("unobtrusiveContainer")}}function m(e){var n=a(e),t=n.data(v),r=a.proxy(l,e),i=p.unobtrusive.options||{},m=function(n,t){var r=i[n];r&&a.isFunction(r)&&r.apply(e,t)};return t||(t={options:{errorClass:i.errorClass||"input-validation-error",errorElement:i.errorElement||"span",errorPlacement:function(){o.apply(e,arguments),m("errorPlacement",arguments)},invalidHandler:function(){d.apply(e,arguments),m("invalidHandler",arguments)},messages:{},rules:{},success:function(){s.apply(e,arguments),m("success",arguments)}},attachValidation:function(){n.off("reset."+v,r).on("reset."+v,r).validate(this.options)},validate:function(){return n.validate(),n.valid()}},n.data(v,t)),t}var u,p=a.validator,v="unobtrusiveValidation";p.unobtrusive={adapters:[],parseElement:function(e,n){var t,r,i,o=a(e),d=o.parents("form")[0];d&&(t=m(d),t.options.rules[e.name]=r={},t.options.messages[e.name]=i={},a.each(this.adapters,function(){var n="data-val-"+this.name,t=o.attr(n),s={};void 0!==t&&(n+="-",a.each(this.params,function(){s[this]=o.attr(n+this)}),this.adapt({element:e,form:d,message:t,params:s,rules:r,messages:i}))}),a.extend(r,{__dummy__:!0}),n||t.attachValidation())},parse:function(e){var n=a(e),t=n.parents().addBack().filter("form").add(n.find("form")).has("[data-val=true]");n.find("[data-val=true]").each(function(){p.unobtrusive.parseElement(this,!0)}),t.each(function(){var a=m(this);a&&a.attachValidation()})}},u=p.unobtrusive.adapters,u.add=function(a,e,n){return n||(n=e,e=[]),this.push({name:a,params:e,adapt:n}),this},u.addBool=function(a,n){return this.add(a,function(t){e(t,n||a,!0)})},u.addMinMax=function(a,n,t,r,i,o){return this.add(a,[i||"min",o||"max"],function(a){var i=a.params.min,o=a.params.max;i&&o?e(a,r,[i,o]):i?e(a,n,i):o&&e(a,t,o)})},u.addSingleVal=function(a,n,t){return this.add(a,[n||"val"],function(r){e(r,t||a,r.params[n])})},p.addMethod("__dummy__",function(a,e,n){return!0}),p.addMethod("regex",function(a,e,n){var t;return this.optional(e)?!0:(t=new RegExp(n).exec(a),t&&0===t.index&&t[0].length===a.length)}),p.addMethod("nonalphamin",function(a,e,n){var t;return n&&(t=a.match(/\W/g),t=t&&t.length>=n),t}),p.methods.extension?(u.addSingleVal("accept","mimtype"),u.addSingleVal("extension","extension")):u.addSingleVal("extension","extension","accept"),u.addSingleVal("regex","pattern"),u.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"),u.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range"),u.addMinMax("minlength","minlength").addMinMax("maxlength","minlength","maxlength"),u.add("equalto",["other"],function(n){var o=r(n.element.name),d=n.params.other,s=i(d,o),l=a(n.form).find(":input").filter("[name='"+t(s)+"']")[0];e(n,"equalTo",l)}),u.add("required",function(a){("INPUT"!==a.element.tagName.toUpperCase()||"CHECKBOX"!==a.element.type.toUpperCase())&&e(a,"required",!0)}),u.add("remote",["url","type","additionalfields"],function(o){var d={url:o.params.url,type:o.params.type||"GET",data:{}},s=r(o.element.name);a.each(n(o.params.additionalfields||o.element.name),function(e,n){var r=i(n,s);d.data[r]=function(){var e=a(o.form).find(":input").filter("[name='"+t(r)+"']");return e.is(":checkbox")?e.filter(":checked").val()||e.filter(":hidden").val()||"":e.is(":radio")?e.filter(":checked").val()||"":e.val()}}),e(o,"remote",d)}),u.add("password",["min","nonalphamin","regex"],function(a){a.params.min&&e(a,"minlength",a.params.min),a.params.nonalphamin&&e(a,"nonalphamin",a.params.nonalphamin),a.params.regex&&e(a,"regex",a.params.regex)}),a(function(){p.unobtrusive.parse(document)})}(jQuery); -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/jquery-validation/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery-validation", 3 | "homepage": "http://jqueryvalidation.org/", 4 | "repository": { 5 | "type": "git", 6 | "url": "git://github.com/jzaefferer/jquery-validation.git" 7 | }, 8 | "authors": [ 9 | "Jörn Zaefferer " 10 | ], 11 | "description": "Form validation made easy", 12 | "main": "dist/jquery.validate.js", 13 | "keywords": [ 14 | "forms", 15 | "validation", 16 | "validate" 17 | ], 18 | "license": "MIT", 19 | "ignore": [ 20 | "**/.*", 21 | "node_modules", 22 | "bower_components", 23 | "test", 24 | "demo", 25 | "lib" 26 | ], 27 | "dependencies": { 28 | "jquery": ">= 1.7.2" 29 | }, 30 | "version": "1.14.0", 31 | "_release": "1.14.0", 32 | "_resolution": { 33 | "type": "version", 34 | "tag": "1.14.0", 35 | "commit": "c1343fb9823392aa9acbe1c3ffd337b8c92fed48" 36 | }, 37 | "_source": "git://github.com/jzaefferer/jquery-validation.git", 38 | "_target": ">=1.8", 39 | "_originalSource": "jquery-validation" 40 | } -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "main": "dist/jquery.js", 4 | "license": "MIT", 5 | "ignore": [ 6 | "package.json" 7 | ], 8 | "keywords": [ 9 | "jquery", 10 | "javascript", 11 | "browser", 12 | "library" 13 | ], 14 | "homepage": "https://github.com/jquery/jquery-dist", 15 | "version": "2.2.0", 16 | "_release": "2.2.0", 17 | "_resolution": { 18 | "type": "version", 19 | "tag": "2.2.0", 20 | "commit": "6fc01e29bdad0964f62ef56d01297039cdcadbe5" 21 | }, 22 | "_source": "git://github.com/jquery/jquery-dist.git", 23 | "_target": "2.2.0", 24 | "_originalSource": "jquery" 25 | } -------------------------------------------------------------------------------- /Mog.Api/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright jQuery Foundation and other contributors, https://jquery.org/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Mog.Api/wwwroot/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MoogleApi", 3 | "short_name": "MoogleApi", 4 | "description": "MoogleApi is your search engine for Final Fantasy. Easily find, and learn more, about your favorite games, characters, and monsters.", 5 | "background_color": "#ffffff", 6 | "theme_color": "#ffffff", 7 | "icons": [ 8 | { 9 | "src": "/icons/moogleapi-icon-192.png", 10 | "sizes": "192x192" 11 | }, 12 | { 13 | "src": "/icons/moogleapi-icon-512.png", 14 | "sizes": "512x512" 15 | } 16 | ], 17 | "display": "standalone", 18 | "orientation": "portrait", 19 | "start_url": "https://www.moogleapi.com" 20 | } -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/ipad_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/ipad_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/ipadpro1_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/ipadpro1_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/ipadpro2_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/ipadpro2_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/ipadpro3_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/ipadpro3_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/iphone5_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/iphone5_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/iphone6_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/iphone6_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/iphoneplus_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/iphoneplus_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/iphonex_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/iphonex_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/iphonexr_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/iphonexr_splash.png -------------------------------------------------------------------------------- /Mog.Api/wwwroot/splashscreens/iphonexsmax_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jackfperryjr/mog/c736df5740c19d16d58c9ad89888c867dc409da9/Mog.Api/wwwroot/splashscreens/iphonexsmax_splash.png -------------------------------------------------------------------------------- /Mog.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26124.0 5 | MinimumVisualStudioVersion = 15.0.26124.0 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mog.Api", "Mog.Api\Mog.Api.csproj", "{FD74DEC5-9F87-4594-9F63-BF352EB54C90}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mog.Api.Core", "Mog.Api.Core\Mog.Api.Core.csproj", "{BB181185-E961-4235-88CC-7054BE1F51A1}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mog.Api.Infrastructure", "Mog.Api.Infrastructure\Mog.Api.Infrastructure.csproj", "{0A3B7A6B-C651-4E0D-8D44-D964198B3C36}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Debug|x64 = Debug|x64 16 | Debug|x86 = Debug|x86 17 | Release|Any CPU = Release|Any CPU 18 | Release|x64 = Release|x64 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(SolutionProperties) = preSolution 22 | HideSolutionNode = FALSE 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Debug|x64.ActiveCfg = Debug|Any CPU 28 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Debug|x64.Build.0 = Debug|Any CPU 29 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Debug|x86.ActiveCfg = Debug|Any CPU 30 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Debug|x86.Build.0 = Debug|Any CPU 31 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Release|Any CPU.Build.0 = Release|Any CPU 33 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Release|x64.ActiveCfg = Release|Any CPU 34 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Release|x64.Build.0 = Release|Any CPU 35 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Release|x86.ActiveCfg = Release|Any CPU 36 | {FD74DEC5-9F87-4594-9F63-BF352EB54C90}.Release|x86.Build.0 = Release|Any CPU 37 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 38 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Debug|Any CPU.Build.0 = Debug|Any CPU 39 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Debug|x64.ActiveCfg = Debug|Any CPU 40 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Debug|x64.Build.0 = Debug|Any CPU 41 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Debug|x86.ActiveCfg = Debug|Any CPU 42 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Debug|x86.Build.0 = Debug|Any CPU 43 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Release|Any CPU.ActiveCfg = Release|Any CPU 44 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Release|Any CPU.Build.0 = Release|Any CPU 45 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Release|x64.ActiveCfg = Release|Any CPU 46 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Release|x64.Build.0 = Release|Any CPU 47 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Release|x86.ActiveCfg = Release|Any CPU 48 | {BB181185-E961-4235-88CC-7054BE1F51A1}.Release|x86.Build.0 = Release|Any CPU 49 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 50 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Debug|Any CPU.Build.0 = Debug|Any CPU 51 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Debug|x64.ActiveCfg = Debug|Any CPU 52 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Debug|x64.Build.0 = Debug|Any CPU 53 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Debug|x86.ActiveCfg = Debug|Any CPU 54 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Debug|x86.Build.0 = Debug|Any CPU 55 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Release|Any CPU.ActiveCfg = Release|Any CPU 56 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Release|Any CPU.Build.0 = Release|Any CPU 57 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Release|x64.ActiveCfg = Release|Any CPU 58 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Release|x64.Build.0 = Release|Any CPU 59 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Release|x86.ActiveCfg = Release|Any CPU 60 | {0A3B7A6B-C651-4E0D-8D44-D964198B3C36}.Release|x86.Build.0 = Release|Any CPU 61 | EndGlobalSection 62 | EndGlobal 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MogleApi 2 | 3 | MoogleApi is a database for all things Final Fantasy. Currently live at www.moogleapi.com! 4 | ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/jackfperryjr/mog) 5 | ![GitHub Release Date](https://img.shields.io/github/release-date/jackfperryjr/mog) 6 | ![GitHub Repo stars](https://img.shields.io/github/stars/jackfperryjr/mog?style=social) 7 | ![Website](https://img.shields.io/website?down_color=lightgrey&down_message=down&up_color=green&up_message=up&url=https%3A%2F%2Fwww.moogleapi.com) 8 | ![visitors](https://visitor-badge.glitch.me/badge?page_id=page.id) 9 | 10 | ### Easy to use! 11 | 12 | Use your favorite front-end framework to send a request: 13 | 14 | https://www.moogleapi.com/api/v1/characters 15 | https://www.moogleapi.com/api/v1/monsters 16 | https://www.moogleapi.com/api/v1/games 17 | https://www.moogleapi.com/api/v1/characters/random 18 | 19 | ### New! ` /search ` route has been added to the Monster and Character controllers! ### 20 | 21 | https://www.moogleapi.com/api/v1/characters/search?name=lightning 22 | https://www.moogleapi.com/api/v1/characters/search?gender=female 23 | https://www.moogleapi.com/api/v1/characters/search?job=l'cie 24 | https://www.moogleapi.com/api/v1/characters/search?race=human 25 | https://www.moogleapi.com/api/v1/characters/search?origin=13 26 | 27 | https://www.moogleapi.com/api/v1/monsters/search?name=chocobo 28 | 29 | ##### *For now the search routes only handle the ` name ` parameter on the Monster controller. More to come! 30 | 31 | Then use that data in your website, webpage, or application! 32 | 33 | ### Examples 34 | 35 | #### JavaScript (super simple example using VueJs and Axios) 36 | 37 | ```javascript 38 | new Vue({ 39 | el: "#vue-app", 40 | mounted: function() { 41 | this.getCharacters() 42 | }, 43 | methods: { 44 | getCharacters() { 45 | axios.get("https://www.moogleapi.com/api/v1/characters") 46 | .then(response => {this.characters = response.data}) 47 | }, 48 | getRandom() { 49 | axios.get("https://www.moogleapi.com/api/v1/characters/random") 50 | .then(response => {this.random = response.data}) 51 | } 52 | data: { 53 | random: {}, 54 | characters: [], 55 | } 56 | }) 57 | ``` 58 | 59 | #### HTML (super simple example) 60 | 61 | ```html 62 |
    63 |
    64 | 65 |
    66 |

    Name: {{random.name}}

    67 |

    Origin: {{random.origin}}

    68 |

    Job/Class: {{random.job}}

    69 |
    70 | 71 |
    72 |
    73 |

    {{character.name}}

    74 |

    {{character.origin}}

    75 |

    {{character.gender}}

    76 | 77 |
    78 |
    79 | ``` 80 | 81 | ##### CDNs I used for VueJs and Axios 82 | ```html 83 | 84 | 85 | ``` 86 | 87 | ### Character properties 88 | 89 | * Name (First and last, if they have one) 90 | * Japanese Name 91 | * Origin (The game they originated in) 92 | * Race 93 | * Gender 94 | * Age 95 | * Job 96 | * Height 97 | * Weight 98 | * Pictures (an array) 99 | * Stats (an array) 100 | * Description 101 | 102 | If I wasn't able to find the data for the character a set of question marks (??) is substituted.
    103 | This is a very simple data set only consisting of the games in the main series (1-15). Although, I'll look into supporting spin-offs as time permits. The data typically refers to the origin of the character, however, more info related to the character's other appearances is usually mentioned in the description. 104 | 105 | ### Monster properties 106 | 107 | * Name 108 | * Japanese name 109 | * Elemental affinity(s) 110 | * Elemental weakness(es) 111 | * Hit points 112 | * Mana points 113 | * Attack 114 | * Defense 115 | * Game 116 | * Picture 117 | * Description 118 | 119 | The monster database is growing! 120 | 121 | ### Game properties 122 | 123 | * Title 124 | * Release Date 125 | * Picture 126 | * Description 127 | 128 | Titles are simple, just 01-15 as of now. Release date refers to the Japanese release, I believe. 129 | 130 | ## Dependencies 131 | ### Client (home/index) 132 | * [jQuery](https://github.com/jquery/jquery) 133 | * [Halfmoon](https://github.com/halfmoonui/halfmoon) 134 | * [Vue](https://github.com/vuejs/vue) 135 | * [Axios](https://github.com/axios/axios) 136 | 137 | ### Server (API) 138 | * [BuildBundlerMinifier](https://www.nuget.org/packages/BuildBundlerMinifier) 139 | * [Swashbuckle.AspNetCore](https://www.nuget.org/packages/Swashbuckle.AspNetCore/) 140 | * [JWT](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.JwtBearer) 141 | * [jwt.io](https://jwt.io/) 142 | * Microsoft stack (NETCore, EFCore, SqlServer, etc.) --------------------------------------------------------------------------------