From 69ae0d30ec08dfc7df604d670c24b89710c906e7 Mon Sep 17 00:00:00 2001 From: jvyden Date: Sat, 11 Dec 2021 12:15:34 -0500 Subject: [PATCH] No longer allow duplicate photos --- ProjectLighthouse/Controllers/PhotosController.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ProjectLighthouse/Controllers/PhotosController.cs b/ProjectLighthouse/Controllers/PhotosController.cs index e96b7a2a..8f8414a7 100644 --- a/ProjectLighthouse/Controllers/PhotosController.cs +++ b/ProjectLighthouse/Controllers/PhotosController.cs @@ -42,6 +42,14 @@ namespace LBPUnion.ProjectLighthouse.Controllers Photo? photo = (Photo?)serializer.Deserialize(new StringReader(bodyString)); if (photo == null) return this.BadRequest(); + foreach (Photo p in this.database.Photos.Where(p => p.CreatorId == user.UserId)) + { + if (p.LargeHash == photo.LargeHash) return this.Ok(); // photo already uplaoded + if (p.MediumHash == photo.MediumHash) return this.Ok(); + if (p.SmallHash == photo.SmallHash) return this.Ok(); + if (p.PlanHash == photo.PlanHash) return this.Ok(); + } + photo.CreatorId = user.UserId; photo.Creator = user;