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
|
||||
NameValidationRequest request = XmlUtil.DeserializeXml<NameValidationRequest>(nameValidationRequest);
|
||||
|
||||
if (request.Category == NameCategory.Default) {
|
||||
// This is an avatar we are checking
|
||||
// Check if viking exists
|
||||
bool exists = ctx.Vikings.Count(e => e.Name == request.Name) > 0;
|
||||
NameValidationResult result = exists ? NameValidationResult.NotUnique : NameValidationResult.Ok;
|
||||
return Ok(new NameValidationResponse { Result = result});
|
||||
|
||||
} else {
|
||||
// TODO: pets, groups, default
|
||||
return Ok();
|
||||
bool exists;
|
||||
switch (request.Category) {
|
||||
case NameCategory.Default:
|
||||
// This is an avatar we are checking
|
||||
// Check if viking exists
|
||||
exists = ctx.Vikings.Any(e => e.Name == request.Name);
|
||||
break;
|
||||
case NameCategory.Group:
|
||||
exists = ctx.Groups.Any(e => e.Name == request.Name);
|
||||
break;
|
||||
default:
|
||||
// TODO: pets, default
|
||||
return Ok();
|
||||
}
|
||||
|
||||
NameValidationResult result = exists ? NameValidationResult.NotUnique : NameValidationResult.Ok;
|
||||
return Ok(new NameValidationResponse { Result = result });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user