From d5e460acf2f9696fcecfa63d91f6b03064b1557f Mon Sep 17 00:00:00 2001 From: Michael <Michael@some.where> Date: Sat, 25 Mar 2017 16:14:31 -0400 Subject: [PATCH] seriously LINQ, can't you be normal --- Project-Unite/Controllers/ManageController.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Project-Unite/Controllers/ManageController.cs b/Project-Unite/Controllers/ManageController.cs index 8bf6b78..5f68eea 100644 --- a/Project-Unite/Controllers/ManageController.cs +++ b/Project-Unite/Controllers/ManageController.cs @@ -42,7 +42,15 @@ namespace Project_Unite.Controllers { string[] allowedTypes = new[] { ".png", ".jpg", ".bmp", ".jpeg", ".gif" }; - bool containsAllowedType = !string.IsNullOrWhiteSpace(allowedTypes.FirstOrDefault(x => model.Image.FileName.EndsWith(x))); + bool containsAllowedType = false; + foreach(var ending in allowedTypes) + { + if (model.Image.FileName.EndsWith(ending)) + { + containsAllowedType = true; + break; + } + } if (containsAllowedType == false) ModelState.AddModelError("UploadImageViewModel", new Exception("File type not allowed."));