public bool ResetPassword(string newPassword, string randomId, string email) { var creationResult = false; try { var ServiceInstance = ServiceLayerProvider.GetInstance(); var searchPassword = Utilities.Encrypt(newPassword); var result = ServiceInstance.CurrentServicelayerInstance.PASSRESET.Where(x => x.Code == randomId.ToUpper() && x.Name == email).FirstOrDefault(); if (result != null) { var user = ServiceInstance.CurrentServicelayerInstance.BusinessPartners.Where(x => x.EmailAddress == email).FirstOrDefault(); if (user != null) { user.U_Password = Utilities.Encrypt(newPassword); ServiceInstance.CurrentServicelayerInstance.UpdateObject(user); var commit = ServiceInstance.CurrentServicelayerInstance.SaveChanges(); if (commit != null) { creationResult = true; } } } } catch (Exception ex) { creationResult = false; Utilities.LogException(ex); } return(creationResult); }
public bool ConfirmEmail(string validationId, string email) { var confirmed = false; try { var ServiceInstance = ServiceLayerProvider.GetInstance(); var result = ServiceInstance.CurrentServicelayerInstance.EMAILCONFIRMATION.Where(x => x.Code == validationId.ToUpper() && x.Name == email).FirstOrDefault(); if (result != null) { var user = ServiceInstance.CurrentServicelayerInstance.BusinessPartners.Where(x => x.EmailAddress == email).FirstOrDefault(); if (user != null) { user.U_Confirmed = "Y"; ServiceInstance.CurrentServicelayerInstance.UpdateObject(user); var commit = ServiceInstance.CurrentServicelayerInstance.SaveChanges(); if (commit != null) { confirmed = true; } } } } catch (Exception ex) { confirmed = false; } return(confirmed); }
public ApplicationUser FindUser(string userName, string password) { ApplicationUser user = null; try { ServiceLayerProvider loginInstance = new ServiceLayerProvider(); loginInstance.Login(); var encryptedPassword = Utilities.Encrypt(password); var result = loginInstance.CurrentServicelayerInstance.BusinessPartners.Where(x => x.U_UserName == userName & x.U_Password == encryptedPassword && x.U_Confirmed == "Y").FirstOrDefault(); if (result != null) { user = new ApplicationUser() { UserName = result.U_UserName, EmailConfirmed = true, FirstName = result.CardName, LastName = result.CardName, Email = result.EmailAddress, UserType = result.CardType, CardCode = result.CardCode }; } } catch (Exception ex) { Utilities.LogException(ex); } return(user); }
public List <Worker> GetWorkers([Optional] string agent) { List <Worker> workersList = new List <Worker>(); try { var ServiceInstance = ServiceLayerProvider.GetInstance(); var workers = ServiceInstance.CurrentServicelayerInstance.WORKERSUDO.ToList <WORKERS>(); foreach (var w in workers) { workersList.Add( new Worker() { Agent = w.U_Agent, BirthDate = w.U_BirthDate.ToString(), CivilId = w.U_CivilId, Code = w.U_ItemCode, Education = w.U_Education, Gender = w.U_Gender, Height = w.U_Height, Language = w.U_Language, MaritalStatus = w.U_MaritalStatus, Nationality = w.U_Nationality, Passport = w.U_Passport, PassportExpDate = MapField <DateTime>(w.U_PassportExpDate).ToString(), PassportIssDate = MapField <DateTime>(w.U_PassportIssDate).ToString(), PassportNumber = w.U_PassportNumber, PassportPoIssue = w.U_PassportPoIssue, Photo = w.U_Photo, Religion = w.U_Religion, SerialNumber = w.U_Serial, Status = w.U_Status, Video = w.U_Video, Weight = w.U_Weight.ToString() } ); } } catch (Exception ex) { Utilities.LogException(ex); } return(workersList); }
public string CreatePasswordReset(string email) { try { var random = Utilities.RandomString(); var ServiceInstance = ServiceLayerProvider.GetInstance(); var password = new PASSRESET(); password.Code = random; password.Name = email; ServiceInstance.CurrentServicelayerInstance.AddToPASSRESET(password); ServiceInstance.CurrentServicelayerInstance.SaveChanges(); return(random); } catch (Exception ex) { Utilities.LogException(ex); return(string.Empty); } }
public string GenerateConfirmationToken(string email) { try { var random = Utilities.RandomString(); var ServiceInstance = ServiceLayerProvider.GetInstance(); var password = new EMAILCONFIRMATION(); password.Code = random; password.Name = email; ServiceInstance.CurrentServicelayerInstance.AddToEMAILCONFIRMATION(password); ServiceInstance.CurrentServicelayerInstance.SaveChanges(); return(random); } catch (Exception ex) { Utilities.LogException(ex); return(string.Empty); } }