public static bool InsertUsuario(Usuario data) { using (InventioEntities context = new InventioEntities()) { context.AddToUsuario(data); context.SaveChanges(); } return true; }
public static bool UpdateUsuario(Usuario data) { using (InventioEntities context = new InventioEntities()) { //data.EntityKey = new EntityKey("InventioEntities.Usuario", "UserName", data.UserName); context.Attach(data); context.ObjectStateManager.GetObjectStateEntry(data).SetModified(); context.Refresh(RefreshMode.ClientWins, data); context.SaveChanges(); } return true; }
/// <summary> /// Creates a new user store he/she in the XML file /// </summary> public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { //XmlDocument doc = new XmlDocument(); //doc.Load(_XmlFileName); //XmlNode xmlUserRoot = doc.CreateElement("User"); //XmlNode xmlUserName = doc.CreateElement("UserName"); //XmlNode xmlPassword = doc.CreateElement("Password"); //XmlNode xmlEmail = doc.CreateElement("Email"); //XmlNode xmlLastLoginTime = doc.CreateElement("LastLoginTime"); Usuario newUsr = new Usuario(); newUsr.UserName = username; newUsr.Password = Encrypt(password); newUsr.Email = email; newUsr.LastLoginTime = DateTime.Now; UsuarioDal.InsertUsuario(newUsr); //xmlUserName.InnerText = username; //xmlPassword.InnerText = Encrypt(password); //xmlEmail.InnerText = email; //xmlLastLoginTime.InnerText = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //xmlUserRoot.AppendChild(xmlUserName); //xmlUserRoot.AppendChild(xmlPassword); //xmlUserRoot.AppendChild(xmlEmail); //xmlUserRoot.AppendChild(xmlLastLoginTime); //doc.SelectSingleNode("Users").AppendChild(xmlUserRoot); //doc.Save(_XmlFileName); status = MembershipCreateStatus.Success; MembershipUser user = new MembershipUser(Name, username, username, email, passwordQuestion, Encrypt(password), isApproved, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.MaxValue); //_Users.Add(username, user); return user; }
/// <summary> /// Create a new Usuario object. /// </summary> /// <param name="email">Initial value of the Email property.</param> /// <param name="lastLoginTime">Initial value of the LastLoginTime property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="userName">Initial value of the UserName property.</param> public static Usuario CreateUsuario(global::System.String email, global::System.DateTime lastLoginTime, global::System.String password, global::System.String userName) { Usuario usuario = new Usuario(); usuario.Email = email; usuario.LastLoginTime = lastLoginTime; usuario.Password = password; usuario.UserName = userName; return usuario; }
/// <summary> /// Deprecated Method for adding a new object to the Usuario EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsuario(Usuario usuario) { base.AddObject("Usuario", usuario); }