public Task <User> FindByNameAsync(string username) { return(Task <User> .Run(() => { User u = null; try { _SpaDatasource.Open(); u = _SpaDatasource.FindUserByName(username); } finally { _SpaDatasource.Close(); } return u; })); }
public ProfileViewModel GetProfile() { ProfileViewModel profile = null; try { Claim subClaim = this.User.Claims.Where(o => o.Type == "sub").FirstOrDefault(); if (subClaim != null) { int id = int.Parse(subClaim.Value); _SpaDatasource.Open(); SpaDatasource.Entitites.User u = _SpaDatasource.FindUserById(id); if (u != null) { profile = new ProfileViewModel { Id = u.Id, FullName = u.FullName, Login = u.Login, Status = u.Status, EmailAddress = u.Email, Country = u.Country, City = u.City, Zip = u.Zip, Address = u.Address }; } } } finally { _SpaDatasource.Close(); } return(profile); }