public HttpResponseMessage Post(int userId) { Try.Action(() => { var userToken = _tokenRepository.Get(userId); DateTime expiredOn = DateTime.Now.AddSeconds( Convert.ToDouble(ConfigurationManager.AppSettings["AuthTokenExpiry"])); if (userToken == null) { string authToken = Guid.NewGuid().ToString(); DateTime issuedOn = DateTime.Now; var token = new Token { UserId = userId, AuthToken = authToken, IssuedOn = issuedOn, ExpiresOn = expiredOn }; _tokenRepository.Post(token); } else { userToken.ExpiresOn = expiredOn; _tokenRepository.Put(userToken); } }); return(new HttpResponseMessage(HttpStatusCode.NoContent)); }
public HttpResponseMessage Delete(string authToken) { Try.Action(() => { var token = _tokenQuery.Get(authToken); _tokenRepository.Delete(token?.ToDomain()); }); return(new HttpResponseMessage(HttpStatusCode.NoContent)); }