public int Handle(ICommand <int> command) { var updateUserCmd = command as UpdateUserCommand; //Validation var validator = new UserValidator(); validator.ValidateAndThrow(updateUserCmd.User); var currentUser = DB.Data.FirstOrDefault(x => x.Id == updateUserCmd.User.Id); //Idempotent!! if (currentUser == null) { throw new InvalidOperationException("User not found"); } currentUser.FirstName = updateUserCmd.User.FirstName; currentUser.LastName = updateUserCmd.User.LastName; currentUser.EmailAddress = updateUserCmd.User.EmailAddress; //Rows affected return(1); }