mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-11-27 10:06:53 -08:00
Added group name validation.
Also made name validation a switch statement (faster).
This commit is contained in:
parent
67732b63e9
commit
67a0b9f360
@ -204,17 +204,23 @@ public class ContentController : Controller {
|
|||||||
// Check if name populated
|
// Check if name populated
|
||||||
NameValidationRequest request = XmlUtil.DeserializeXml<NameValidationRequest>(nameValidationRequest);
|
NameValidationRequest request = XmlUtil.DeserializeXml<NameValidationRequest>(nameValidationRequest);
|
||||||
|
|
||||||
if (request.Category == NameCategory.Default) {
|
bool exists;
|
||||||
|
switch (request.Category) {
|
||||||
|
case NameCategory.Default:
|
||||||
// This is an avatar we are checking
|
// This is an avatar we are checking
|
||||||
// Check if viking exists
|
// Check if viking exists
|
||||||
bool exists = ctx.Vikings.Count(e => e.Name == request.Name) > 0;
|
exists = ctx.Vikings.Any(e => e.Name == request.Name);
|
||||||
NameValidationResult result = exists ? NameValidationResult.NotUnique : NameValidationResult.Ok;
|
break;
|
||||||
return Ok(new NameValidationResponse { Result = result});
|
case NameCategory.Group:
|
||||||
|
exists = ctx.Groups.Any(e => e.Name == request.Name);
|
||||||
} else {
|
break;
|
||||||
// TODO: pets, groups, default
|
default:
|
||||||
|
// TODO: pets, default
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NameValidationResult result = exists ? NameValidationResult.NotUnique : NameValidationResult.Ok;
|
||||||
|
return Ok(new NameValidationResponse { Result = result });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user