public async Task <ActionResult <Citizen> > Login([FromBody] CNPContainer container) { var cnp = await _mediator.Send(container); if (cnp == null) { return(NotFound()); } return(Ok(cnp)); }
public async Task <Tuple <Citizen, Guid> > Handle(CNPContainer request, CancellationToken cancellationToken) { var citizen = _context.Citizens.SingleOrDefault(c => c.CNP == request.CNP); await _context.SaveChangesAsync(cancellationToken); LoginToken token = LoginToken.Create(citizen.ID); _login_context.LoginTokens.Add(token); await _login_context.SaveChangesAsync(cancellationToken); return(new Tuple <Citizen, Guid>(citizen, token.Get())); }