I'm using various resources to try and implement an Identity system with MS Access for an AngularJS app. I created classes which implement the Identity interfaces I need, and I'm stuck at the stage of creating the Account controller (which will be the API for registeration, login, etc).
The class UserStore
implements IUserStore
and has the CreateAsync
method:
public Task CreateAsync(TUser user)
{
if (user == null)
{
throw new ArgumentNullException("user");
}
var result = userTable.Insert(user);
return Task.FromResult(result);
}
AccountController
implements ApiController
and has the Register
method:
[AllowAnonymous]
[Route("register")]
public async Task<IHttpActionResult> Register(IdentityUser user)
{
var result = await _userStore.CreateAsync(user);
if (result == 0)
{
return InternalServerError();
}
return Ok();
}
userTable.Insert(user)
returns an int
indicating the number of rows affected in the DB table. The line var result = await _userStore.CreateAsync(user);
throws an error, saying it actually returns void
, and so void
cannot be assigned to var
(or to anything else).
I'm having a hard time understanding how to write the Register
method and the CreateAsync
method so that they will work together.
BTW, I thought I should give up the whole async
thing and just make CreateAsync
and Register
return the int value as-is, but I can't do that since UserStore
implements `IUserStore'.