//Sign up public bool SignUp(LoginRequest request) { var emails = _userProfileRepository.GetSingleNoneDeleted(x => x.Email == request.Email); if (emails != null) { return(false); } //add new var newUserProfile = new UserProfile { UserName = request.UserName, Email = request.Email, Password = CryptoMd5.Encode(request.Password), CreatedBy = Constants.GetUserId(), ModifiedBy = Constants.GetUserId(), CreatedDate = Constants.GetDateNow(), ModifiedDate = Constants.GetDateNow() }; _userProfileRepository.Add(newUserProfile); var isOk = _userProfileRepository.Commit(); if (isOk) { try { //get mail template to send var email = new EmailViewModel { From = "Web Master <*****@*****.**>", Body = "inspectionPackFunc.openFormAddNewInspectionLocationDefinition('5133991c-192b-4154-9f26-9ab9cbfb89ad','f459d32e-adfc-460f-b00e-d36703f8f69c')", To = newUserProfile.Email, Cc = "*****@*****.**", Subject = "test mail", Bcc = "", Attachments = "" }; XMail.Send(email); } catch (Exception) { // ignored } } return(isOk); }
public Guid?Login(LoginRequest request) { var email = _userProfileRepository.GetSingleNoneDeleted(x => x.Email == request.Email); var pwd = CryptoMd5.Encode(request.Password); if (email != null && pwd == email.Password) { var newUserLoginHistory = new UserLoginHistory { UserId = Constants.GetUserId(), AccessToken = Guid.NewGuid(), IsAppToken = true, IsLoggedOut = false, CreatedBy = Constants.GetUserId(), ModifiedBy = Constants.GetUserId(), CreatedDate = Constants.GetDateNow(), ModifiedDate = Constants.GetDateNow() }; _userLoginHistoryRepository.Add(newUserLoginHistory); _userLoginHistoryRepository.Commit(); return(newUserLoginHistory.AccessToken); } return(null); }