public void ChangeCurrentTown() { ModifyUserValidator.TownNotFound(this.NewValue); ChangeTownID(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(string.Format(ModifyMessage.Success, this.Username, this.Property, this.NewValue)); }
// ModifyUser <username> <property> <new value> // For example: // ModifyUser <username> Password <NewPassword> // ModifyUser <username> BornTown <newBornTownName> // ModifyUser <username> CurrentTown <newCurrentTownName> // !!! Cannot change username public void Parse(string[] commandData) { ModifyUserValidator.InvalidParameters(commandData.Length); this.Username = commandData[1]; this.Property = commandData[2]; this.NewValue = commandData[3]; }
public void Execute() { ModifyUserValidator.UserNotFound(this.Username); ModifyUserValidator.PropertyNotFound(this.Property); var exeMethods = typeof(ModifyUserCommand).GetMethods() .SingleOrDefault(m => m.Name.ToLower().Contains(this.Property.ToLower())) .Invoke(new ModifyUserCommand(), new object[] { }); }
public void ChangePassword() { ModifyUserValidator.InvalidPassword(this.NewValue); context.Users.SingleOrDefault(u => u.Username == this.Username).Password = this.NewValue; context.SaveChanges(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(string.Format(ModifyMessage.Success, this.Username, this.Property, this.NewValue)); }