seriously LINQ, can't you be normal

This commit is contained in:
Michael 2017-03-25 16:14:31 -04:00
parent 9c4f703176
commit d5e460acf2

View file

@ -42,7 +42,15 @@ namespace Project_Unite.Controllers
{ {
string[] allowedTypes = new[] { ".png", ".jpg", ".bmp", ".jpeg", ".gif" }; 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) if (containsAllowedType == false)
ModelState.AddModelError("UploadImageViewModel", new Exception("File type not allowed.")); ModelState.AddModelError("UploadImageViewModel", new Exception("File type not allowed."));