예제 #1
0
        public Result <ResetPasswordRequest> GetMail(string emailOrUserName)
        {
            var result = new Result <ResetPasswordRequest>();

            try
            {
                var userInfoObject = DbContext.UserInfos.FirstOrDefault(u => u.UserName.Equals(emailOrUserName.Trim()) || u.Email.Equals(emailOrUserName));
                if (userInfoObject == null)
                {
                    result.HasError = true;
                    result.Message  = "Email/UserName is not exist";
                    return(result);
                }
                string guid = Guid.NewGuid().ToString();
                ForgotPassword.SendPasswordResetEmail(userInfoObject.Email, userInfoObject.Name, guid);
                var objToSave = new ResetPasswordRequest();
                objToSave.UserID    = userInfoObject.ID;
                objToSave.RequestOn = DateTime.Now;
                objToSave.GUID      = guid;
                DbContext.ResetPasswordRequests.Add(objToSave);

                DbContext.SaveChanges();

                result.Data = objToSave;
            }
            catch (Exception ex)
            {
                result.HasError = true;
                result.Message  = ex.Message;
            }
            return(result);
        }