mirror of
https://github.com/lempamo/Project-Unite.git
synced 2025-04-21 00:30:23 +00:00
seriously LINQ, can't you be normal
This commit is contained in:
parent
9c4f703176
commit
d5e460acf2
1 changed files with 9 additions and 1 deletions
|
@ -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."));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue