Adds support for SIREN exceptions to validation from the external provider

This commit is contained in:
2016-07-27 11:46:51 +02:00
parent f09a5ec2ca
commit e6d81a72b2

View File

@ -262,7 +262,8 @@ namespace Yavsc.Controllers
if (credential == null)
return RedirectToAction("LinkLogin", new { provider = "Google" });
try {
try
{
ViewBag.Calendars = new GoogleApis.CalendarApi(_googleSettings.ApiKey)
.GetCalendars(credential);
}
@ -485,16 +486,28 @@ namespace Yavsc.Controllers
{
var user = GetCurrentUserAsync().Result;
var uid = user.Id;
try { 
try
{
if (ModelState.IsValid)
{
var exSiren = await _dbContext.ExceptionsSIREN.FirstOrDefaultAsync(
ex => ex.SIREN == model.SIREN
);
if (exSiren != null)
{
_logger.LogInformation("Exception SIREN:"+exSiren);
}
else
{
var taskCheck = await _cchecker.CheckAsync(model.SIREN);
if (!taskCheck.success) {
if (!taskCheck.success)
{
ModelState.AddModelError(
"SIREN",
_SR["Invalid company number"] + " (" + taskCheck.errorCode + ")"
);
_logger.LogWarning("Invalid company number, using key:"+_cinfoSettings.ApiKey);
_logger.LogInformation("Invalid company number, using key:" + _cinfoSettings.ApiKey);
}
}
}
}