Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="newPassword"></param>
        /// <returns></returns>
        public string UpdatePassword(int userId, string newPassword)
        {
            User userQuery = new User();

            try
            {
                using (TimeInEntities context = new TimeInEntities())
                {
                    userQuery = context.Users.Where(x => x.UserKey == userId && x.IsActive == true).FirstOrDefault();

                    userQuery.UserPassword = newPassword;
                    userQuery.UpdateDttm   = DateTime.Now;
                    userQuery.UpdateUserId = userQuery.UserName;

                    context.Users.Attach(userQuery);
                    context.Entry(userQuery).State = System.Data.Entity.EntityState.Modified;
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return("User record updated.");
        }