public UserDetails Authentication(string userEmail, string pass) { try { StoredProcedureDataContext dbmlObject = new StoredProcedureDataContext(); var databaseResult = dbmlObject.LoginAuthenticationWithCompanyDetails(userEmail, pass).ToList(); if (databaseResult.Count == 0) { throw new Exception(); } var loggedUser = databaseResult.First(); UserDetails user = new UserDetails(); user.CompanyId = loggedUser.CompanyID; user.FirstName = loggedUser.FirstName; user.IsOwner = loggedUser.IsOwner; user.LastName = loggedUser.LastName; user.UserId = loggedUser.UserID; user.UserDashboards = GetUserDashboards(loggedUser.UserID); user.CompanyName = loggedUser.Name; return(user); } catch (Exception e) { throw e; } }