public DT_AuthenticateEntity GetUser(string userName, string password) { using (Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities()) { // string encodedpassword = decode(password); password = Encryption.AESEncryptString(password, "", ""); //password = Encryption.AesDecryptString(password, "", ""); DT_AuthenticateEntity DTpatients = (from user in rehab.tblUsers.Where(a => a.UserId == userName && a.UserPassword == password) join usergrp in rehab.tblUserGroups on user.UserGroup equals usergrp.UGrowid select new DT_AuthenticateEntity { FirstName = user.FirstName, LastName = user.LastName, UserID = user.UserId, Role = usergrp.UserGroup //PhoneNumber = therapist.LastName, //Email = therapist.LastName } ).Distinct().ToList().FirstOrDefault(); return(DTpatients); //if (DTpatients != null) //{ // return DTpatients; //} //else //{ // throw new UnauthorizedAccessException(); //} } }
//[ResponseType(typeof(DT_AuthenticateEntity))] public DT_AuthenticateEntity PostAdmin(string userName) { DT_AuthenticateEntity response = new DT_AuthenticateEntity(); response = _directtrustpatientRepository.GetUserOnUsername(userName); //if (response != null) //{ return(response); //} //else //{ // throw new ApiDataException(1000, "user not found", HttpStatusCode.NotFound); //} }
public DT_AuthenticateEntity GetUserOnUsername(string userName) { using (Team.Rehab.DataModel.RehabEntities rehab = new RehabEntities()) { // string encodedpassword = decode(password); //password = Encryption.AesDecryptString(password, "", ""); DT_AuthenticateEntity DTpatients = (from user in rehab.tblUsers.Where(a => a.UserEmail == userName) join usergrp in rehab.tblUserGroups on user.UserGroup equals usergrp.UGrowid select new DT_AuthenticateEntity { FirstName = user.FirstName, LastName = user.LastName, UserID = user.UserId, Role = usergrp.UserGroup } ).Distinct().ToList().FirstOrDefault(); return(DTpatients); } }